-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Use common.mustCall in http test
PR-URL: #17487 Refs: #17169 Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
- Loading branch information
1 parent
7f2764d
commit af8e27d
Showing
1 changed file
with
4 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,24 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const common = require('../common'); | ||
const http = require('http'); | ||
const net = require('net'); | ||
|
||
const COUNT = 10; | ||
|
||
let received = 0; | ||
|
||
const server = http.createServer(function(req, res) { | ||
const server = http.createServer(common.mustCall((req, res) => { | ||
// Close the server, we have only one TCP connection anyway | ||
if (received++ === 0) | ||
server.close(); | ||
|
||
server.close(); | ||
res.writeHead(200); | ||
res.write('data'); | ||
|
||
setTimeout(function() { | ||
res.end(); | ||
}, (Math.random() * 100) | 0); | ||
}).listen(0, function() { | ||
}, COUNT)).listen(0, function() { | ||
const s = net.connect(this.address().port); | ||
|
||
const big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT); | ||
|
||
s.write(big); | ||
s.resume(); | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert.strictEqual(received, COUNT); | ||
}); |