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) {
|
function emitCloseNT(self) {
|
||||||
if (!self.destroyed) {
|
if (!self._closed) {
|
||||||
self.destroyed = true;
|
self.destroyed = true;
|
||||||
self._closed = true;
|
self._closed = true;
|
||||||
self.emit('close');
|
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…
x
Reference in New Issue
Block a user