mirror of https://github.com/nodejs/node.git
http: adding doc and debug for calling empty string on write function
PR-URL: https://github.com/nodejs/node/pull/22118 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>pull/22355/merge
parent
98cf84f2c9
commit
413a7e1dea
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue