Skip to content

Commit

Permalink
http: Adding doc and debug for calling empty string on write function
Browse files Browse the repository at this point in the history
  • Loading branch information
antsmartian authored and Trott committed Aug 22, 2018
1 parent 36468ca commit 725923f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,9 @@ Returns `true` if the entire data was flushed successfully to the kernel
buffer. Returns `false` if all or part of the data was queued in user memory.
`'drain'` will be emitted when the buffer is free again.

When `write` function is called with empty string or buffer, it does
nothing and waits for more input.

## Class: http.Server
<!-- YAML
added: v0.1.17
Expand Down
5 changes: 4 additions & 1 deletion lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,10 @@ function write_(msg, chunk, encoding, callback, fromEnd) {

// If we get an empty string or buffer, then just do nothing, and
// signal the user to keep writing.
if (chunk.length === 0) return true;
if (chunk.length === 0) {
debug('received empty string or buffer and waiting for more input');
return true;
}

if (!fromEnd && msg.connection && !msg[kIsCorked]) {
msg.connection.cork();
Expand Down

0 comments on commit 725923f

Please sign in to comment.