-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: call write callback even if there is no message body #27777
Conversation
Ensure that the callback of `OutgoingMessage.prototype.write()` is called when `outgoingMessage._hasBody` is `false` (HEAD method, 204 status code, etc.). Refs: nodejs#27709
@@ -573,6 +573,7 @@ function write_(msg, chunk, encoding, callback, fromEnd) { | |||
if (!msg._hasBody) { | |||
debug('This type of response MUST NOT have a body. ' + | |||
'Ignoring write() calls.'); | |||
if (callback) process.nextTick(callback); |
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.
We could replace chunk
with an empty chunk and continue without bailing out, but I think it makes sense to short circuit here as all chunks are ignored.
Could this conceivably be a breaking change? |
I'm not sure, can't think of anything that would break. The same applies to #27709 anyway. |
Landed in 2a850cd |
Ensure that the callback of `OutgoingMessage.prototype.write()` is called when `outgoingMessage._hasBody` is `false` (HEAD method, 204 status code, etc.). Refs: nodejs#27709 PR-URL: nodejs#27777 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
Ensure that the callback of
OutgoingMessage.prototype.write()
iscalled when
outgoingMessage._hasBody
isfalse
(HEAD method, 204status code, etc.).
Refs: #27709
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes