forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: wait for pending responses in closeIdleConnections
PR-URL: nodejs#43890 Fixes: nodejs#43771 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
- Loading branch information
1 parent
8989394
commit 220ef0e
Showing
2 changed files
with
30 additions
and
0 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
26 changes: 26 additions & 0 deletions
26
test/parallel/test-http-server-close-idle-wait-response.js
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const { createServer, get } = require('http'); | ||
|
||
const server = createServer(common.mustCall(function(req, res) { | ||
req.resume(); | ||
|
||
setTimeout(common.mustCall(() => { | ||
res.writeHead(204, { 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=1' }); | ||
res.end(); | ||
}), common.platformTimeout(1000)); | ||
})); | ||
|
||
server.listen(0, function() { | ||
const port = server.address().port; | ||
|
||
get(`http://localhost:${port}`, common.mustCall((res) => { | ||
server.close(); | ||
})).on('finish', common.mustCall(() => { | ||
setTimeout(common.mustCall(() => { | ||
server.closeIdleConnections(); | ||
}), common.platformTimeout(500)); | ||
})); | ||
}); |