From 6f613d8abb05619e35c828b665a76215861bbf04 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Fri, 2 Aug 2019 08:09:06 +0200 Subject: [PATCH] http,stream: add writableEnded This is work towards resolving the response.finished confusion and future deprecation. Note that implementation-wise, streams have both an ending and ended state. However, in this case (in order to avoid confusion in user space) writableEnded is equal to writable.ending. The ending vs ended situation is internal state required for internal stream logic. PR-URL: https://github.com/nodejs/node/pull/28934 Reviewed-By: Matteo Collina Reviewed-By: Trivikram Kamat Reviewed-By: Benjamin Gruenbaum Reviewed-By: Rich Trott --- doc/api/http.md | 34 +++++++++++++++++++ doc/api/http2.md | 12 +++++++ doc/api/stream.md | 13 +++++++ lib/_http_outgoing.js | 4 +++ lib/_stream_duplex.js | 16 +++++++-- lib/_stream_writable.js | 14 ++++++-- lib/internal/http2/compat.js | 5 +++ .../test-http-outgoing-finish-writable.js | 2 ++ .../test-http2-compat-serverresponse-end.js | 2 ++ ...st-http2-compat-serverresponse-finished.js | 2 ++ .../test-stream-writable-ended-state.js | 4 +++ 11 files changed, 103 insertions(+), 5 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index 4923b6a61d840f..d5851b61dbba3c 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -764,6 +764,27 @@ req.once('response', (res) => { }); ``` +### request.writableEnded + + +* {boolean} + +Is `true` after [`request.end()`][] has been called. This property +does not indicate whether the data has been flushed, for this use +[`request.writableFinished`][] instead. + +### request.writableFinished + + +* {boolean} + +Is `true` if all data has been flushed to the underlying system, immediately +before the [`'finish'`][] event is emitted. + ### request.write(chunk[, encoding][, callback]) + +* {boolean} + +Is `true` after [`response.end()`][] has been called. This property +does not indicate whether the data has been flushed, for this use +[`response.writableFinished`][] instead. + ### response.writableFinished + +* {boolean} + +Is `true` after [`response.end()`][] has been called. This property +does not indicate whether the data has been flushed, for this use +[`writable.writableFinished`][] instead. + #### response.write(chunk[, encoding][, callback]) + +* {boolean} + +Is `true` after [`writable.end()`][] has been called. This property +does not indicate whether the data has been flushed, for this use +[`writable.writableFinished`][] instead. + ##### writable.writableFinished