mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
http: fix http client leaky with double response
PR-URL: https://github.com/nodejs/node/pull/60062 Fixes: https://github.com/nodejs/node/issues/60025 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
@@ -41,6 +41,7 @@ const {
|
||||
} = incoming;
|
||||
|
||||
const kIncomingMessage = Symbol('IncomingMessage');
|
||||
const kSkipPendingData = Symbol('SkipPendingData');
|
||||
const kOnMessageBegin = HTTPParser.kOnMessageBegin | 0;
|
||||
const kOnHeaders = HTTPParser.kOnHeaders | 0;
|
||||
const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
|
||||
@@ -126,7 +127,7 @@ function parserOnBody(b) {
|
||||
const stream = this.incoming;
|
||||
|
||||
// If the stream has already been removed, then drop it.
|
||||
if (stream === null)
|
||||
if (stream === null || stream[kSkipPendingData])
|
||||
return;
|
||||
|
||||
// Pretend this was the result of a stream._read call.
|
||||
@@ -141,7 +142,7 @@ function parserOnMessageComplete() {
|
||||
const parser = this;
|
||||
const stream = parser.incoming;
|
||||
|
||||
if (stream !== null) {
|
||||
if (stream !== null && !stream[kSkipPendingData]) {
|
||||
stream.complete = true;
|
||||
// Emit any trailing headers.
|
||||
const headers = parser._headers;
|
||||
@@ -310,4 +311,5 @@ module.exports = {
|
||||
HTTPParser,
|
||||
isLenient,
|
||||
prepareError,
|
||||
kSkipPendingData,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user