Guard against emitting 'end' twice on http responses
This commit is contained in:
parent
ea4b1c1c0c
commit
14a5b45c06
10
lib/http.js
10
lib/http.js
@ -125,7 +125,10 @@ function parserOnMessageComplete() {
|
|||||||
if (!parser.incoming.upgrade) {
|
if (!parser.incoming.upgrade) {
|
||||||
// For upgraded connections, also emit this after parser.execute
|
// For upgraded connections, also emit this after parser.execute
|
||||||
parser.incoming.readable = false;
|
parser.incoming.readable = false;
|
||||||
parser.incoming.emit('end');
|
if (!parser.incoming._ended) {
|
||||||
|
parser.incoming._ended = true;
|
||||||
|
parser.incoming.emit('end');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.socket.readable) {
|
if (parser.socket.readable) {
|
||||||
@ -1158,7 +1161,10 @@ function socketCloseListener() {
|
|||||||
if (req.res && req.res.readable) {
|
if (req.res && req.res.readable) {
|
||||||
// Socket closed before we emitted "end" below.
|
// Socket closed before we emitted "end" below.
|
||||||
req.res.emit('aborted');
|
req.res.emit('aborted');
|
||||||
req.res.emit('end');
|
if (!req.res._ended) {
|
||||||
|
req.res._ended = true;
|
||||||
|
req.res.emit('end');
|
||||||
|
}
|
||||||
req.res.emit('close');
|
req.res.emit('close');
|
||||||
} else if (!req.res && !req._hadError) {
|
} else if (!req.res && !req._hadError) {
|
||||||
// This socket error fired before we started to
|
// This socket error fired before we started to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user