-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
0\r\n\r\n
in TE HEAD responses
When replying to a HEAD request, do not attempt to send the trailers and EOF sequence (`0\r\n\r\n`). The HEAD request MUST not have body. Quote from RFC: The presence of a message body in a response depends on both the request method to which it is responding and the response status code (Section 3.1.2). Responses to the HEAD request method (Section 4.3.2 of [RFC7231]) never include a message body because the associated response header fields (e.g., Transfer-Encoding, Content-Length, etc.), if present, indicate only what their values would have been if the request method had been GET (Section 4.3.1 of [RFC7231]). fix #8361 Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -945,6 +945,10 @@ OutgoingMessage.prototype.end = function(data, encoding) { | |
if (encoding === 'hex' || encoding === 'base64') | ||
hot = false; | ||
|
||
// Transfer-encoding: chunked responses to HEAD requests | ||
if (this._hasBody && this.chunkedEncoding) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
indutny
Author
Member
|
||
hot = false; | ||
|
||
if (hot) { | ||
// Hot path. They're doing | ||
// res.writeHead(); | ||
|
@@ -982,7 +986,7 @@ OutgoingMessage.prototype.end = function(data, encoding) { | |
} | ||
|
||
if (!hot) { | ||
if (this.chunkedEncoding) { | ||
if (this._hasBody && this.chunkedEncoding) { | ||
ret = this._send('0\r\n' + this._trailer + '\r\n', 'ascii'); | ||
} else { | ||
// Force a flush, HACK. | ||
|
7 comments
on commit 1fddc1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@indutny @tjfontaine This is causing test-http-many-keep-alive-connections.js
to stall indefinitely. I'll try to take a look, but would one of you two mind also taking a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that it is related to this patch? Also, I'm failing to reproduce it, but I'd suspect that it is related to creating 10000 connection, which could sometimes overflow ephemeral ports on the machine...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now all I know for sure is that when I build 6e689ec (parent of this commit) the test completes successfully. And it doesn't on this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have an environment configuration description such that we can reproduce it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correction I see it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right we're now hitting 1fddc1f#diff-1c0f1c434b17b7f8795d44a51a14320aR992 instead of the hot path case for writeHead(); end()
and always forcing a flush, resulting in the test slowing down drastically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this have been a
if (!this._hasBody && this.chunkedEncoding)
in order to match the comment? i.e. HEAD responses do not have a body.