mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
http: response should always emit 'close'
Fixes: https://github.com/nodejs/node/issues/40528 PR-URL: https://github.com/nodejs/node/pull/40543 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
070b54a4ac
commit
3b9044b5b2
@ -839,7 +839,7 @@ function resOnFinish(req, res, socket, state, server) {
|
||||
}
|
||||
|
||||
function emitCloseNT(self) {
|
||||
if (!self.destroyed) {
|
||||
if (!self._closed) {
|
||||
self.destroyed = true;
|
||||
self._closed = true;
|
||||
self.emit('close');
|
||||
|
@ -78,3 +78,25 @@ const assert = require('assert');
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
const server = http.createServer(
|
||||
common.mustCall((req, res) => {
|
||||
res.on('close', common.mustCall());
|
||||
res.destroy();
|
||||
})
|
||||
);
|
||||
|
||||
server.listen(
|
||||
0,
|
||||
common.mustCall(() => {
|
||||
http.get(
|
||||
{ port: server.address().port },
|
||||
common.mustNotCall()
|
||||
)
|
||||
.on('error', common.mustCall(() => {
|
||||
server.close();
|
||||
}));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user