Permalink
Browse files

http: always emit close on req and res

PR-URL: #20611
Fixes: #20600
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information...
ronag authored and trivikr committed May 8, 2018
1 parent eafb30c commit f22c7c10ca0c8c7a10057de71bc423bf8b633b88
Showing with 18 additions and 0 deletions.
  1. +2 −0 lib/_http_server.js
  2. +16 −0 test/parallel/test-http-req-res-close.js
View
@@ -561,6 +561,8 @@ function resOnFinish(req, res, socket, state, server) {
req._dump();
res.detachSocket(socket);
req.emit('close');
res.emit('close');
if (res._last) {
if (typeof socket.destroySoon === 'function') {
@@ -0,0 +1,16 @@
'use strict';
const common = require('../common');
const http = require('http');
const server = http.Server(common.mustCall((req, res) => {
res.end();
res.on('finish', common.mustCall());
res.on('close', common.mustCall());
req.on('close', common.mustCall());
res.socket.on('close', () => server.close());
}));
server.listen(0, common.mustCall(() => {
http.get({ port: server.address().port }, common.mustCall());
}));

0 comments on commit f22c7c1

Please sign in to comment.