Skip to content

Commit c07a065

Browse files
antsmartiantargos
authored andcommitted
http: adding doc and debug for calling empty string on write function
PR-URL: #22118 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 53fb7af commit c07a065

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

doc/api/http.md

+3
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,9 @@ Returns `true` if the entire data was flushed successfully to the kernel
744744
buffer. Returns `false` if all or part of the data was queued in user memory.
745745
`'drain'` will be emitted when the buffer is free again.
746746

747+
When `write` function is called with empty string or buffer, it does
748+
nothing and waits for more input.
749+
747750
## Class: http.Server
748751
<!-- YAML
749752
added: v0.1.17

lib/_http_outgoing.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,10 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
599599

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

604607
if (!fromEnd && msg.connection && !msg[kIsCorked]) {
605608
msg.connection.cork();

0 commit comments

Comments
 (0)