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>
This commit is contained in:
Anto Aravinth authored and Matteo Collina committed 2018-08-22 09:48:09 +02:00
1 parent 98cf84f2c9
commit 413a7e1dea
2 files changed
+7 -1

No files matched your search

+3
View File
@@ -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
+4 -1
View File
@@ -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();