中止流


🌐 Aborting a stream

QuicStream 可以通过三种方式中止,每种方式都会产生不同的传输帧副作用:

🌐 A QuicStream can be aborted in three ways, each producing different wire-frame side effects:

  • writer.fail(reason) — 仅中止可写的一侧。向对端发送 RESET_STREAM。可读的一侧不受影响;任何已经缓冲的可读数据仍然可用。
  • stream.destroy() 使用 error 参数 — 完全中断流。向任何仍然打开的可写端发送 RESET_STREAM,并向任何仍然打开的可读端发送 STOP_SENDING。该线代码源自 error(优先规则见 stream.destroy())。
  • stream.destroy() 带有一个显式的 options.code — 与之前的形式相同,但使用调用者提供的线路代码,该代码优先于 error 所携带的任何代码。

errorQuicError 时,其 error.errorCode 用作 writer.fail()stream.destroy() 的线码。否则,实现将回退到协商的应用协议的“内部错误”代码(参见 QuicError)。

🌐 When error is a QuicError, its error.errorCode is used as the wire code for both writer.fail() and stream.destroy(). Otherwise the implementation falls back to the negotiated application protocol's "internal error" code (see QuicError).