mirror of https://github.com/nodejs/node.git
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: https://github.com/nodejs/node/pull/6198 PR-URL: https://github.com/nodejs/node/pull/6279 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>pull/6288/head
parent
7f14483352
commit
9d4d529517
|
@ -432,7 +432,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) {
|
|||
// Responses to CONNECT request is handled as Upgrade.
|
||||
if (req.method === 'CONNECT') {
|
||||
res.upgrade = true;
|
||||
return true; // skip body
|
||||
return 2; // skip body, and the rest
|
||||
}
|
||||
|
||||
// Responses to HEAD requests are crazy.
|
||||
|
|
|
@ -96,7 +96,7 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method,
|
|||
|
||||
parser.incoming.upgrade = upgrade;
|
||||
|
||||
var skipBody = false; // response to HEAD or CONNECT
|
||||
var skipBody = 0; // response to HEAD or CONNECT
|
||||
|
||||
if (!upgrade) {
|
||||
// For upgraded connections and CONNECT method request, we'll emit this
|
||||
|
@ -105,7 +105,10 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method,
|
|||
skipBody = parser.onIncoming(parser.incoming, shouldKeepAlive);
|
||||
}
|
||||
|
||||
return skipBody;
|
||||
if (typeof skipBody !== 'number')
|
||||
return skipBody ? 1 : 0;
|
||||
else
|
||||
return skipBody;
|
||||
}
|
||||
|
||||
// XXX This is a mess.
|
||||
|
|
|
@ -300,7 +300,7 @@ class Parser : public AsyncWrap {
|
|||
return -1;
|
||||
}
|
||||
|
||||
return head_response->IsTrue() ? 1 : 0;
|
||||
return head_response->IntegerValue();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue