From 8979e0d7617d7fe78e5a5dc01bee3c542b760402 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sat, 25 Nov 2017 13:02:16 -0800 Subject: [PATCH] http2: use 'close' event instead of 'streamClosed' PR-URL: https://github.com/nodejs/node/pull/17328 Fixes: https://github.com/nodejs/node/issues/15303 Reviewed-By: Anatoli Papirovski Reviewed-By: Sebastiaan Deckers --- doc/api/http2.md | 26 +++++++++---------- lib/internal/http2/compat.js | 4 +-- lib/internal/http2/core.js | 8 +++--- .../test-http2-client-http1-server.js | 2 +- ...t-http2-client-rststream-before-connect.js | 2 +- ...p2-client-stream-destroy-before-connect.js | 2 +- .../test-http2-client-unescaped-path.js | 2 +- .../test-http2-compat-serverresponse-end.js | 4 +-- test/parallel/test-http2-compat-socket.js | 4 +-- test/parallel/test-http2-multiheaders-raw.js | 2 +- test/parallel/test-http2-multiheaders.js | 2 +- ...test-http2-options-max-reserved-streams.js | 6 ++--- .../test-http2-respond-file-errors.js | 2 +- .../test-http2-respond-file-fd-errors.js | 2 +- .../test-http2-respond-file-fd-range.js | 4 +-- test/parallel/test-http2-respond-no-data.js | 2 +- .../parallel/test-http2-response-splitting.js | 2 +- .../test-http2-server-rst-before-respond.js | 2 +- test/parallel/test-http2-server-rst-stream.js | 2 +- .../parallel/test-http2-server-socketerror.js | 2 +- test/parallel/test-http2-stream-client.js | 2 +- .../test-http2-stream-destroy-event-order.js | 2 +- test/parallel/test-http2-too-large-headers.js | 2 +- test/parallel/test-http2-too-many-headers.js | 2 +- test/parallel/test-http2-write-callbacks.js | 2 +- 25 files changed, 45 insertions(+), 47 deletions(-) diff --git a/doc/api/http2.md b/doc/api/http2.md index 356081fd78a48f..7ae796ec478d23 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -631,7 +631,7 @@ All [`Http2Stream`][] instances are destroyed either when: When an `Http2Stream` instance is destroyed, an attempt will be made to send an `RST_STREAM` frame will be sent to the connected peer. -Once the `Http2Stream` instance is destroyed, the `'streamClosed'` event will +When the `Http2Stream` instance is destroyed, the `'close'` event will be emitted. Because `Http2Stream` is an instance of `stream.Duplex`, the `'end'` event will also be emitted if the stream data is currently flowing. The `'error'` event may also be emitted if `http2stream.destroy()` was called @@ -653,6 +653,18 @@ abnormally aborted in mid-communication. *Note*: The `'aborted'` event will only be emitted if the `Http2Stream` writable side has not been ended. +#### Event: 'close' + + +The `'close'` event is emitted when the `Http2Stream` is destroyed. Once +this event is emitted, the `Http2Stream` instance is no longer usable. + +The listener callback is passed a single argument specifying the HTTP/2 error +code specified when closing the stream. If the code is any value other than +`NGHTTP2_NO_ERROR` (`0`), an `'error'` event will also be emitted. + #### Event: 'error' - -The `'streamClosed'` event is emitted when the `Http2Stream` is destroyed. Once -this event is emitted, the `Http2Stream` instance is no longer usable. - -The listener callback is passed a single argument specifying the HTTP/2 error -code specified when closing the stream. If the code is any value other than -`NGHTTP2_NO_ERROR` (`0`), an `'error'` event will also be emitted. - #### Event: 'timeout'