| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -631,7 +631,7 @@ All [`Http2Stream`][] instances are destroyed either when: | |||
| 631 | 631 | When an `Http2Stream` instance is destroyed, an attempt will be made to send an | |
| 632 | 632 | `RST_STREAM` frame will be sent to the connected peer. | |
| 633 | 633 | ||
| 634 | - Once the `Http2Stream` instance is destroyed, the `'streamClosed'` event will | ||
| 634 | + When the `Http2Stream` instance is destroyed, the `'close'` event will | ||
| 635 | 635 | be emitted. Because `Http2Stream` is an instance of `stream.Duplex`, the | |
| 636 | 636 | `'end'` event will also be emitted if the stream data is currently flowing. | |
| 637 | 637 | The `'error'` event may also be emitted if `http2stream.destroy()` was called | |
@@ -653,6 +653,18 @@ abnormally aborted in mid-communication. | |||
| 653 | 653 | *Note*: The `'aborted'` event will only be emitted if the `Http2Stream` | |
| 654 | 654 | writable side has not been ended. | |
| 655 | 655 | ||
| 656 | + #### Event: 'close' | ||
| 657 | + <!-- YAML | ||
| 658 | + added: v8.4.0 | ||
| 659 | + --> | ||
| 660 | + | ||
| 661 | + The `'close'` event is emitted when the `Http2Stream` is destroyed. Once | ||
| 662 | + this event is emitted, the `Http2Stream` instance is no longer usable. | ||
| 663 | + | ||
| 664 | + The listener callback is passed a single argument specifying the HTTP/2 error | ||
| 665 | + code specified when closing the stream. If the code is any value other than | ||
| 666 | + `NGHTTP2_NO_ERROR` (`0`), an `'error'` event will also be emitted. | ||
| 667 | + | ||
| 656 | 668 | #### Event: 'error' | |
| 657 | 669 | <!-- YAML | |
| 658 | 670 | added: v8.4.0 | |
@@ -672,18 +684,6 @@ argument identifying the frame type, and an integer argument identifying the | |||
| 672 | 684 | error code. The `Http2Stream` instance will be destroyed immediately after the | |
| 673 | 685 | `'frameError'` event is emitted. | |
| 674 | 686 | ||
| 675 | - #### Event: 'streamClosed' | ||
| 676 | - <!-- YAML | ||
| 677 | - added: v8.4.0 | ||
| 678 | - --> | ||
| 679 | - | ||
| 680 | - The `'streamClosed'` event is emitted when the `Http2Stream` is destroyed. Once | ||
| 681 | - this event is emitted, the `Http2Stream` instance is no longer usable. | ||
| 682 | - | ||
| 683 | - The listener callback is passed a single argument specifying the HTTP/2 error | ||
| 684 | - code specified when closing the stream. If the code is any value other than | ||
| 685 | - `NGHTTP2_NO_ERROR` (`0`), an `'error'` event will also be emitted. | ||
| 686 | - | ||
| 687 | 687 | #### Event: 'timeout' | |
| 688 | 688 | <!-- YAML | |
| 689 | 689 | added: v8.4.0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -250,7 +250,7 @@ class Http2ServerRequest extends Readable { | |||
| 250 | 250 | stream.on('close', onStreamClosedRequest); | |
| 251 | 251 | stream.on('aborted', onStreamAbortedRequest); | |
| 252 | 252 | const onfinish = this[kFinish].bind(this); | |
| 253 | - stream.on('streamClosed', onfinish); | ||
| 253 | + stream.on('close', onfinish); | ||
| 254 | 254 | stream.on('finish', onfinish); | |
| 255 | 255 | this.on('pause', onRequestPause); | |
| 256 | 256 | this.on('resume', onRequestResume); | |
@@ -383,7 +383,7 @@ class Http2ServerResponse extends Stream { | |||
| 383 | 383 | stream.on('close', onStreamClosedResponse); | |
| 384 | 384 | stream.on('aborted', onStreamAbortedResponse); | |
| 385 | 385 | const onfinish = this[kFinish].bind(this); | |
| 386 | - stream.on('streamClosed', onfinish); | ||
| 386 | + stream.on('close', onfinish); | ||
| 387 | 387 | stream.on('finish', onfinish); | |
| 388 | 388 | } | |
| 389 | 389 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -224,10 +224,8 @@ function onStreamTrailers() { | |||
| 224 | 224 | return headersList; | |
| 225 | 225 | } | |
| 226 | 226 | ||
| 227 | - // Called when the stream is closed. The streamClosed event is emitted on the | ||
| 228 | - // Http2Stream instance. Note that this event is distinctly different than the | ||
| 229 | - // require('stream') interface 'close' event which deals with the state of the | ||
| 230 | - // Readable and Writable sides of the Duplex. | ||
| 227 | + // Called when the stream is closed. The close event is emitted on the | ||
| 228 | + // Http2Stream instance | ||
| 231 | 229 | function onStreamClose(code) { | |
| 232 | 230 | const stream = this[kOwner]; | |
| 233 | 231 | stream[kUpdateTimer](); | |
@@ -1475,7 +1473,7 @@ function continueStreamDestroy(err, callback) { | |||
| 1475 | 1473 | abort(this); | |
| 1476 | 1474 | this.push(null); // Close the readable side | |
| 1477 | 1475 | this.end(); // Close the writable side | |
| 1478 | - process.nextTick(emit, this, 'streamClosed', code); | ||
| 1476 | + process.nextTick(emit, this, 'close', code); | ||
| 1479 | 1477 | } | |
| 1480 | 1478 | ||
| 1481 | 1479 | function finishStreamDestroy() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ server.listen(0, common.mustCall(() => { | |||
| 13 | 13 | const client = http2.connect(`http://localhost:${server.address().port}`); | |
| 14 | 14 | ||
| 15 | 15 | const req = client.request(); | |
| 16 | - req.on('streamClosed', common.mustCall()); | ||
| 16 | + req.on('close', common.mustCall()); | ||
| 17 | 17 | ||
| 18 | 18 | client.on('error', common.expectsError({ | |
| 19 | 19 | code: 'ERR_HTTP2_ERROR', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,7 @@ server.on('listening', common.mustCall(() => { | |||
| 27 | 27 | // second call doesn't do anything | |
| 28 | 28 | assert.doesNotThrow(() => req.rstStream(8)); | |
| 29 | 29 | ||
| 30 | - req.on('streamClosed', common.mustCall((code) => { | ||
| 30 | + req.on('close', common.mustCall((code) => { | ||
| 31 | 31 | assert.strictEqual(req.destroyed, true); | |
| 32 | 32 | assert.strictEqual(code, 0); | |
| 33 | 33 | server.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,7 @@ server.on('listening', common.mustCall(() => { | |||
| 41 | 41 | })(err); | |
| 42 | 42 | })); | |
| 43 | 43 | ||
| 44 | - req.on('streamClosed', common.mustCall((code) => { | ||
| 44 | + req.on('close', common.mustCall((code) => { | ||
| 45 | 45 | assert.strictEqual(req.rstCode, NGHTTP2_INTERNAL_ERROR); | |
| 46 | 46 | assert.strictEqual(code, NGHTTP2_INTERNAL_ERROR); | |
| 47 | 47 | server.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ server.listen(0, common.mustCall(() => { | |||
| 30 | 30 | type: Error, | |
| 31 | 31 | message: 'Stream closed with error code 1' | |
| 32 | 32 | })); | |
| 33 | - req.on('streamClosed', common.mustCall(maybeClose)); | ||
| 33 | + req.on('close', common.mustCall(maybeClose)); | ||
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | 36 | for (let i = 0; i <= count; i += 1) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -183,10 +183,10 @@ const { | |||
| 183 | 183 | ||
| 184 | 184 | ||
| 185 | 185 | { | |
| 186 | - // Should be able to call .end with cb from stream 'streamClosed' | ||
| 186 | + // Should be able to call .end with cb from stream 'close' | ||
| 187 | 187 | const server = createServer(mustCall((request, response) => { | |
| 188 | 188 | response.writeHead(HTTP_STATUS_OK, { foo: 'bar' }); | |
| 189 | - response.stream.on('streamClosed', mustCall(() => { | ||
| 189 | + response.stream.on('close', mustCall(() => { | ||
| 190 | 190 | response.end(mustCall()); | |
| 191 | 191 | })); | |
| 192 | 192 | })); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,8 +64,8 @@ server.on('request', common.mustCall(function(request, response) { | |||
| 64 | 64 | assert.strictEqual(request.socket.connecting, false); | |
| 65 | 65 | ||
| 66 | 66 | // socket events are bound and emitted on Http2Stream | |
| 67 | - request.socket.on('streamClosed', common.mustCall()); | ||
| 68 | - request.socket.once('streamClosed', common.mustCall()); | ||
| 67 | + request.socket.on('close', common.mustCall()); | ||
| 68 | + request.socket.once('close', common.mustCall()); | ||
| 69 | 69 | request.socket.on('testEvent', common.mustCall()); | |
| 70 | 70 | request.socket.emit('testEvent'); | |
| 71 | 71 | })); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,7 @@ server.on('stream', common.mustCall((stream, headers, flags, rawHeaders) => { | |||
| 42 | 42 | server.listen(0, common.mustCall(() => { | |
| 43 | 43 | const client = http2.connect(`http://localhost:${server.address().port}`); | |
| 44 | 44 | const req = client.request(src); | |
| 45 | - req.on('streamClosed', common.mustCall(() => { | ||
| 45 | + req.on('close', common.mustCall(() => { | ||
| 46 | 46 | server.close(); | |
| 47 | 47 | client.destroy(); | |
| 48 | 48 | })); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments