Skip to content

Commit f6969a1

Browse files
indutnyMylesBorins
authored andcommitted
http: skip body and next message of CONNECT res
When handling a response to `CONNECT` request - skip message body and do not attempt to parse the next message. `CONNECT` requests are used in similar sense to HTTP Upgrade. Fix: #6198 PR-URL: #6279 Reviewed-By: Brian White <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b7dd451 commit f6969a1

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/_http_client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) {
432432
// Responses to CONNECT request is handled as Upgrade.
433433
if (req.method === 'CONNECT') {
434434
res.upgrade = true;
435-
return true; // skip body
435+
return 2; // skip body, and the rest
436436
}
437437

438438
// Responses to HEAD requests are crazy.

lib/_http_common.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method,
9494

9595
parser.incoming.upgrade = upgrade;
9696

97-
var skipBody = false; // response to HEAD or CONNECT
97+
var skipBody = 0; // response to HEAD or CONNECT
9898

9999
if (!upgrade) {
100100
// For upgraded connections and CONNECT method request, we'll emit this
@@ -103,7 +103,10 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method,
103103
skipBody = parser.onIncoming(parser.incoming, shouldKeepAlive);
104104
}
105105

106-
return skipBody;
106+
if (typeof skipBody !== 'number')
107+
return skipBody ? 1 : 0;
108+
else
109+
return skipBody;
107110
}
108111

109112
// XXX This is a mess.

src/node_http_parser.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ class Parser : public AsyncWrap {
300300
return -1;
301301
}
302302

303-
return head_response->IsTrue() ? 1 : 0;
303+
return head_response->IntegerValue();
304304
}
305305

306306

0 commit comments

Comments
 (0)