From 82af8acc8e8b99f8b50401ffe977113fbe033b9e Mon Sep 17 00:00:00 2001 From: Alba Mendez Date: Mon, 27 Apr 2020 03:15:07 +0200 Subject: [PATCH] http2,doc: minor fixes Some small fixes on HTTP/2 and its documentation: - Add a note that, on server streams, it's not necessary to start data flow. - Set EOF flag if we have marked all data for sending: there's no need to wait until the queue is actually empty (and send a separate, empty DATA). (Note that, even with this change, a separate DATA frame will always be sent, because the streams layer waits until data has been flushed before dispatching EOF) Backport-PR-URL: https://github.com/nodejs/node/pull/34845 PR-URL: https://github.com/nodejs/node/pull/28044 Reviewed-By: Matteo Collina Reviewed-By: Anna Henningsen --- doc/api/http2.md | 5 +++-- src/node_http2.cc | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/api/http2.md b/doc/api/http2.md index 00837bfc0e413b..219a837c06d12f 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -927,8 +927,9 @@ the value is `undefined`, the stream is not yet ready for use. All [`Http2Stream`][] instances are destroyed either when: * An `RST_STREAM` frame for the stream is received by the connected peer, - and pending data has been read. -* The `http2stream.close()` method is called, and pending data has been read. + and (for client streams only) pending data has been read. +* The `http2stream.close()` method is called, and (for client streams only) + pending data has been read. * The `http2stream.destroy()` or `http2session.destroy()` methods are called. When an `Http2Stream` instance is destroyed, an attempt will be made to send an diff --git a/src/node_http2.cc b/src/node_http2.cc index 76ef72005a3087..566a1b7c55c3f5 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -2367,7 +2367,7 @@ ssize_t Http2Stream::Provider::Stream::OnRead(nghttp2_session* handle, return NGHTTP2_ERR_DEFERRED; } - if (stream->queue_.empty() && !stream->IsWritable()) { + if (stream->available_outbound_length_ == 0 && !stream->IsWritable()) { Debug(session, "no more data for stream %d", id); *flags |= NGHTTP2_DATA_FLAG_EOF; if (stream->HasTrailers()) {