阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js Http2Stream 的生命周期

      Node.js Http2Stream 的生命周期

      创建

      On the server side, instances of ServerHttp2Stream are created either when:

      • A new HTTP/2 HEADERS frame with a previously unused stream ID is received;
      • The http2stream.pushStream() method is called.

      On the client side, instances of ClientHttp2Stream are created when the http2session.request() method is called.

      On the client, the Http2Stream instance returned by http2session.request() may not be immediately ready for use if the parent Http2Session has not yet been fully established. In such cases, operations called on the Http2Stream will be buffered until the ‘ready’ event is emitted. User code should rarely, if ever, need to handle the ‘ready’ event directly. The ready status of an Http2Stream can be determined by checking the value of http2stream.id. If 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.
      • The http2stream.close() method is called.
      • The http2stream.destroy() or http2session.destroy() methods are called.

      When an Http2Stream instance is destroyed, an attempt will be made to send an RST_STREAM frame will be sent to the connected peer.

      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 with an Error passed as the first argument.

      After the Http2Stream has been destroyed, the http2stream.destroyed property will be true and the http2stream.rstCode property will specify the RST_STREAM error code. The Http2Stream instance is no longer usable once destroyed.


      更多内容请参考:Node.js HTTP2,或者通过 点击对应菜单 进行查看;


      目录
      本文目录
      目录