Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 07fd52e

Browse filesBrowse files
indutnyMyles Borins
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 <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e06ab64 commit 07fd52e
Copy full SHA for 07fd52e

File tree

Expand file treeCollapse file tree

3 files changed

+7
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+7
-4
lines changed
Open diff view settings
Collapse file

‎lib/_http_client.js‎

Copy file name to clipboardExpand all lines: lib/_http_client.js
+1-1Lines changed: 1 addition & 1 deletion
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.
Collapse file

‎lib/_http_common.js‎

Copy file name to clipboardExpand all lines: lib/_http_common.js
+5-2Lines changed: 5 additions & 2 deletions
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.
Collapse file

‎src/node_http_parser.cc‎

Copy file name to clipboardExpand all lines: src/node_http_parser.cc
+1-1Lines changed: 1 addition & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.