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

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
http: call write callback even if there is no message body
Ensure that the callback of `OutgoingMessage.prototype.write()` is
called when `outgoingMessage._hasBody` is `false` (HEAD method, 204
status code, etc.).

Refs: #27709
@nodejs-github-bot

This comment has been minimized.

@@ -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);

This comment has been minimized.

Copy link
@lpinca

lpinca May 20, 2019

Author Member

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

This comment has been minimized.

Copy link
Member

commented May 30, 2019

Could this conceivably be a breaking change?

@lpinca

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

@Trott
Trott approved these changes Jun 1, 2019
@Trott

This comment has been minimized.

Copy link
Member

commented Jun 1, 2019

Landed in 2a850cd

@Trott Trott closed this Jun 1, 2019

Trott added a commit to Trott/io.js that referenced this pull request Jun 1, 2019
http: call write callback even if there is no message body
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 added a commit that referenced this pull request Jun 1, 2019
http: call write callback even if there is no message body
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 referenced this pull request Jun 3, 2019

@lpinca lpinca deleted the lpinca:call/outgoing-message-write-callback branch Jun 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.