| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,33 +1,24 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 3 | - const assert = require('assert'); | ||
| 2 | + const common = require('../common'); | ||
| 4 | 3 | const http = require('http'); | |
| 5 | 4 | const net = require('net'); | |
| 6 | 5 | ||
| 7 | 6 | const COUNT = 10; | |
| 8 | 7 | ||
| 9 | - let received = 0; | ||
| 10 | - | ||
| 11 | - const server = http.createServer(function(req, res) { | ||
| 8 | + const server = http.createServer(common.mustCall((req, res) => { | ||
| 12 | 9 | // Close the server, we have only one TCP connection anyway | |
| 13 | - if (received++ === 0) | ||
| 14 | - server.close(); | ||
| 15 | - | ||
| 10 | + server.close(); | ||
| 16 | 11 | res.writeHead(200); | |
| 17 | 12 | res.write('data'); | |
| 18 | 13 | ||
| 19 | 14 | setTimeout(function() { | |
| 20 | 15 | res.end(); | |
| 21 | 16 | }, (Math.random() * 100) | 0); | |
| 22 | - }).listen(0, function() { | ||
| 17 | + }, COUNT)).listen(0, function() { | ||
| 23 | 18 | const s = net.connect(this.address().port); | |
| 24 | 19 | ||
| 25 | 20 | const big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT); | |
| 26 | 21 | ||
| 27 | 22 | s.write(big); | |
| 28 | 23 | s.resume(); | |
| 29 | 24 | }); | |
| 30 | - | ||
| 31 | - process.on('exit', function() { | ||
| 32 | - assert.strictEqual(received, COUNT); | ||
| 33 | - }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments