http: revert "http: always emit close on req and res"
This reverts a commit that accidentally introduced a semver-major change to Node 10 and broke userland code. A subsequent fix to that change and documentation change are reverted with it. Revert "http: fix res emit close before user finish" This reverts commit2a9c83321b
. Revert "http: always emit close on req and res" This reverts commit8029a2473e
. Revert "doc: fix HTTP req/res 'close' description" This reverts commit8ab7ea6eed
. PR-URL: https://github.com/nodejs/node/pull/21809 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
This commit is contained in:
Родитель
3d05d82353
Коммит
8799f43fb0
|
@ -1015,7 +1015,8 @@ interface. This is an [`EventEmitter`][] with the following events:
|
|||
added: v0.6.7
|
||||
-->
|
||||
|
||||
Indicates that the underlying connection was terminated.
|
||||
Indicates that the underlying connection was terminated before
|
||||
[`response.end()`][] was called or able to flush.
|
||||
|
||||
### Event: 'finish'
|
||||
<!-- YAML
|
||||
|
@ -1505,6 +1506,7 @@ added: v0.4.2
|
|||
-->
|
||||
|
||||
Indicates that the underlying connection was closed.
|
||||
Just like `'end'`, this event occurs only once per response.
|
||||
|
||||
### message.aborted
|
||||
<!-- YAML
|
||||
|
|
|
@ -561,8 +561,6 @@ function resOnFinish(req, res, socket, state, server) {
|
|||
req._dump();
|
||||
|
||||
res.detachSocket(socket);
|
||||
req.emit('close');
|
||||
process.nextTick(emitCloseNT, res);
|
||||
|
||||
if (res._last) {
|
||||
if (typeof socket.destroySoon === 'function') {
|
||||
|
@ -585,10 +583,6 @@ function resOnFinish(req, res, socket, state, server) {
|
|||
}
|
||||
}
|
||||
|
||||
function emitCloseNT(self) {
|
||||
self.emit('close');
|
||||
}
|
||||
|
||||
// The following callback is issued after the headers have been read on a
|
||||
// new message. In this callback we setup the response object and pass it
|
||||
// to the user.
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const http = require('http');
|
||||
const assert = require('assert');
|
||||
|
||||
const server = http.Server(common.mustCall((req, res) => {
|
||||
let resClosed = false;
|
||||
|
||||
res.end();
|
||||
res.on('finish', common.mustCall(() => {
|
||||
assert.strictEqual(resClosed, false);
|
||||
}));
|
||||
res.on('close', common.mustCall(() => {
|
||||
resClosed = true;
|
||||
}));
|
||||
req.on('close', common.mustCall(() => {
|
||||
assert.strictEqual(req._readableState.ended, true);
|
||||
}));
|
||||
res.socket.on('close', () => server.close());
|
||||
}));
|
||||
|
||||
server.listen(0, common.mustCall(() => {
|
||||
http.get({ port: server.address().port }, common.mustCall());
|
||||
}));
|
Загрузка…
Ссылка в новой задаче