Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-07-14 13:49:14 +0300
committerMichaël Zasso <targos@protonmail.com>2018-08-01 18:22:35 +0300
commit8799f43fb0626d4453f7ff7d9d20d4075adf7784 (patch)
tree446b6e2f5f2a002b484615254ef8eb36a7618f48
parent3d05d82353da6f3c544320e30003f457147775a5 (diff)
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 commit 2a9c83321b7893395d9472755290c31acf4228a4. Revert "http: always emit close on req and res" This reverts commit 8029a2473e032c5006d2dfc3044bdce1b221dee4. Revert "doc: fix HTTP req/res 'close' description" This reverts commit 8ab7ea6eed76d069dfd82684e2157e7d88badebf. 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>
-rw-r--r--doc/api/http.md4
-rw-r--r--lib/_http_server.js6
-rw-r--r--test/parallel/test-http-req-res-close.js25
3 files changed, 3 insertions, 32 deletions
diff --git a/doc/api/http.md b/doc/api/http.md
index fd8bb02776d..e83c507bf2e 100644
--- a/doc/api/http.md
+++ b/doc/api/http.md
@@ -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
diff --git a/lib/_http_server.js b/lib/_http_server.js
index 3d5a1f8f624..8e0cbfbf266 100644
--- a/lib/_http_server.js
+++ b/lib/_http_server.js
@@ -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.
diff --git a/test/parallel/test-http-req-res-close.js b/test/parallel/test-http-req-res-close.js
deleted file mode 100644
index daba55f4342..00000000000
--- a/test/parallel/test-http-req-res-close.js
+++ /dev/null
@@ -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());
-}));