session.onstream


  • 类型:quic.OnStreamCallback

当远程端启动新流时要调用的回调。可读/写。

🌐 The callback to invoke when a new stream is initiated by a remote peer. Read/write.

如果没有设置 onstream 回调,并且该流没有其他消费者,那么流在到达时会被销毁,并发出一个警告。当协商的应用协议支持时(例如 HTTP/3),onheaders 回调会被算作消费者,因为它会在每个传入的请求流上调用。其他流级别的回调(ontrailers、oninfo、onwanttrailers)则不会,因为它们是有条件的或仅用于出站,会导致流无法被观察到。完全通过 onheaders 处理请求的 HTTP/3 服务器不需要设置 onstream。

🌐 If no onstream callback is set and the stream has no other consumer, an incoming stream is destroyed on arrival and a warning is emitted. An onheaders callback counts as a consumer when the negotiated application protocol supports it (e.g. HTTP/3), because it is invoked for every incoming request stream. Other stream-level callbacks (ontrailers, oninfo, onwanttrailers) do not, since they are conditional or outbound-only and would leave the stream unobservable. An HTTP/3 server that handles requests entirely through onheaders does not need to set onstream.