session.createUnidirectionalStream([options])


  • options <Object>
    • body <string> | <ArrayBuffer> | <SharedArrayBuffer> | <ArrayBufferView> | <Blob> | <FileHandle> | <AsyncIterable> | <Iterable> | <Promise> | <null> 出站主体源。有关支持的类型,请参见 stream.setBody()。省略时,流会立即关闭。
    • headers <Object> 要发送的初始请求头。
    • priority <string> 流的优先级别。可选值为 'high''default''low'默认值: 'default'
    • incremental <boolean>true 时,该流的数据可能会与同一优先级的其他流的数据交错。 当 false 时,该流应在同优先级的同伴之前完成。 默认: false
    • highWaterMark <number>writeSync() 返回 false 之前,写入器将缓冲的最大字节数。当缓冲的数据超过此限制时,调用者应在写入更多数据之前等待清空。默认值: 65536(64 KB)。
    • onheaders <Function> 接收到初始响应头时的回调。 使用 (headers) 调用。
    • ontrailers <Function> 接收尾部头的回调。调用时使用 (trailers)
    • oninfo <Function> 收到信息性(1xx)头时的回调。使用 (headers) 调用。
    • onwanttrailers <Function> 在应该发送标尾时的回调。
  • 返回:<Promise> 用于 quic.QuicStream

打开一个新的单向流。如果未指定 body 选项,出站流将被关闭。priorityincremental 选项仅在会话支持优先级时使用(例如 HTTP/3)。

🌐 Open a new unidirectional stream. If the body option is not specified, the outgoing stream will be closed. The priority and incremental options are only used when the session supports priority (e.g. HTTP/3).