Skip to content
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

Closed

Conversation

lpinca
Copy link
Member

@lpinca lpinca commented May 20, 2019

Ensure that the callback of OutgoingMessage.prototype.write() is
called when outgoingMessage._hasBody is false (HEAD method, 204
status code, etc.).

Refs: #27709

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Ensure that the callback of `OutgoingMessage.prototype.write()` is
called when `outgoingMessage._hasBody` is `false` (HEAD method, 204
status code, etc.).

Refs: nodejs#27709
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label May 20, 2019
@@ -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);
Copy link
Member Author

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.

@Trott
Copy link
Member

Trott commented May 30, 2019

Could this conceivably be a breaking change?

@lpinca
Copy link
Member Author

lpinca commented May 30, 2019

I'm not sure, can't think of anything that would break. The same applies to #27709 anyway.

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Jun 1, 2019

Landed in 2a850cd

@Trott Trott closed this Jun 1, 2019
Trott pushed a commit to Trott/io.js that referenced this pull request Jun 1, 2019
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>
targos pushed a commit that referenced this pull request Jun 1, 2019
Ensure that the callback of `OutgoingMessage.prototype.write()` is
called when `outgoingMessage._hasBody` is `false` (HEAD method, 204
status code, etc.).

Refs: #27709

PR-URL: #27777
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@targos targos mentioned this pull request Jun 3, 2019
@lpinca lpinca deleted the call/outgoing-message-write-callback branch June 8, 2019 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants