From 43f2799d13592c15afcddf64100ee38fe59937ca Mon Sep 17 00:00:00 2001 From: Kenichi Ishibashi Date: Wed, 15 Sep 2021 16:17:10 +0900 Subject: [PATCH] WebTransport: Add workaround for server-initiated streams --- tools/webtransport/h3/webtransport_h3_server.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/webtransport/h3/webtransport_h3_server.py b/tools/webtransport/h3/webtransport_h3_server.py index ae5404b71302c1..5c72b1ae9c2b55 100644 --- a/tools/webtransport/h3/webtransport_h3_server.py +++ b/tools/webtransport/h3/webtransport_h3_server.py @@ -10,7 +10,7 @@ # TODO(bashi): Remove import check suppressions once aioquic dependency is resolved. from aioquic.asyncio import QuicConnectionProtocol, serve # type: ignore from aioquic.asyncio.client import connect # type: ignore -from aioquic.h3.connection import H3_ALPN, H3Connection # type: ignore +from aioquic.h3.connection import H3_ALPN, FrameType, H3Connection # type: ignore from aioquic.h3.events import H3Event, HeadersReceived, WebTransportStreamDataReceived, DatagramReceived # type: ignore from aioquic.quic.configuration import QuicConfiguration # type: ignore from aioquic.quic.connection import stream_is_unidirectional # type: ignore @@ -187,6 +187,13 @@ def create_bidirectional_stream(self) -> int: """ stream_id = self._http.create_webtransport_stream( session_id=self.session_id, is_unidirectional=False) + # TODO(bashi): Remove this workaround when aioquic supports receiving + # data on server-initiated bidirectional streams. + stream = self._http._get_or_create_stream(stream_id) + assert stream.frame_type is None + assert stream.session_id is None + stream.frame_type = FrameType.WEBTRANSPORT_STREAM + stream.session_id = self.session_id return stream_id def send_stream_data(self,