Skip to content

Commit 07fd52e

Browse files
indutnyMyles Borins
authored and
Myles Borins
committed
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 e06ab64 commit 07fd52e

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
@@ -393,7 +393,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) {
393393
// Responses to CONNECT request is handled as Upgrade.
394394
if (req.method === 'CONNECT') {
395395
res.upgrade = true;
396-
return true; // skip body
396+
return 2; // skip body, and the rest
397397
}
398398

399399
// 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
@@ -301,7 +301,7 @@ class Parser : public AsyncWrap {
301301
return -1;
302302
}
303303

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

307307

0 commit comments

Comments
 (0)