Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e411692

Browse files
committedApr 19, 2016
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: nodejs#6198
1 parent aebdf6f commit e411692

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
@@ -96,7 +96,7 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method,
9696

9797
parser.incoming.upgrade = upgrade;
9898

99-
var skipBody = false; // response to HEAD or CONNECT
99+
var skipBody = 0; // response to HEAD or CONNECT
100100

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

108-
return skipBody;
108+
if (typeof skipBody !== 'number')
109+
return skipBody ? 1 : 0;
110+
else
111+
return skipBody;
109112
}
110113

111114
// 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)
Please sign in to comment.