Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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
  • Loading branch information
indutny committed Apr 19, 2016
commit e4116920d58f6bca093f1c4270b33f8d838231a4
2 changes: 1 addition & 1 deletion lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -105,7 +105,10 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method,
skipBody = parser.onIncoming(parser.incoming, shouldKeepAlive);
}

return skipBody;
if (typeof skipBody !== 'number')
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anyone is curious - this is for compatibility with external code. (like node-spdy)

return skipBody ? 1 : 0;
else
return skipBody;
}

// XXX This is a mess.
Expand Down
2 changes: 1 addition & 1 deletion src/node_http_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class Parser : public AsyncWrap {
return -1;
}

return head_response->IsTrue() ? 1 : 0;
return head_response->IntegerValue();
}


Expand Down