Skip to content
Closed
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
add comment
  • Loading branch information
indutny committed Dec 18, 2015
commit f64bf3282115163def1b7a2a495a3e43ff23204b
3 changes: 3 additions & 0 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method,
// supported protocols.
//
// See RFC7230 Section 6.7
//
// NOTE: RegExp below matches `upgrade` in `Connection: abc, upgrade, def`
// header.
if (upgrade &&
Copy link
Member

Choose a reason for hiding this comment

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

seems like a kludge that we are doing this here, isn't this more appropriate for http_parser if it's getting it wrong?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure. Is http-parser aware of the outgoing request? If not, I think the fix here is valid.

Copy link
Member Author

Choose a reason for hiding this comment

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

@silverwind has valid point

Copy link
Contributor

Choose a reason for hiding this comment

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

@indutny what do you think about only emitting 'upgrade' if both headers are present in the response? That way the decision could be based purely on the response and could be done in http-parser. All three use cases of the upgrade header require both headers to be present in both the request and the response.

Copy link
Member Author

Choose a reason for hiding this comment

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

Wait, how does http-parser know about response headers? Also, I think I require both headers now, am I not?

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it http-parser which sets the upgrade argument based on the response header here?

And yeah, you require both header on the request. I still think the upgrade decision could be solely based on the response headers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or rather, scrap that. I re-read that rfc7230 part, and the advertisement can include both headers, so knowledge of request and response is necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Of course 😉

parser.outgoing !== null &&
(parser.outgoing._headers.upgrade === undefined ||
Expand Down