diff options
author | Anto Aravinth <anto.aravinth.cse@gmail.com> | 2018-08-21 19:50:04 +0530 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2018-08-22 09:48:09 +0200 |
commit | 413a7e1deabaf5f0daa633df6e594f8cc1503a12 (patch) | |
tree | 4c95c5b3553a03a56e433cc3b20653c179cd19fe | |
parent | 98cf84f2c9d13386362386eac6089bc356c017b2 (diff) | |
download | android-node-v8-413a7e1deabaf5f0daa633df6e594f8cc1503a12.tar.gz android-node-v8-413a7e1deabaf5f0daa633df6e594f8cc1503a12.tar.bz2 android-node-v8-413a7e1deabaf5f0daa633df6e594f8cc1503a12.zip |
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>
-rw-r--r-- | doc/api/http.md | 3 | ||||
-rw-r--r-- | lib/_http_outgoing.js | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/doc/api/http.md b/doc/api/http.md index 49a98d5f17..e781d63ac4 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -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 diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 7fe4e2133b..67d0090d7d 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -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(); |