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 2018-08-21 19:50:04 +05:30 коммит произвёл Michaël Zasso
Родитель 53fb7af1b2
Коммит c07a065699
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 770F7A9A5AE15600
2 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -744,6 +744,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();