StopQuicStream -> StopSendingQuicStream

This commit is contained in:
Maximilian Hils 2024-08-18 18:34:31 +02:00 committed by Maximilian Hils
parent 3464842a13
commit a81a1d3555
4 changed files with 10 additions and 8 deletions

View File

@ -39,7 +39,7 @@ from mitmproxy.proxy import layer
from mitmproxy.proxy.layers.quic import error_code_to_str
from mitmproxy.proxy.layers.quic import QuicConnectionClosed
from mitmproxy.proxy.layers.quic import QuicStreamEvent
from mitmproxy.proxy.layers.quic import StopQuicStream
from mitmproxy.proxy.layers.quic import StopSendingQuicStream
from mitmproxy.proxy.utils import expect
@ -125,7 +125,7 @@ class Http3Connection(HttpConnection):
if event.stream_id in self._stream_protocol_errors:
# we already reset or ended the stream, tell the peer to stop
# (this is a noop if the peer already did the same)
yield StopQuicStream(
yield StopSendingQuicStream(
self.conn,
event.stream_id,
self._stream_protocol_errors[event.stream_id],

View File

@ -198,7 +198,7 @@ class ResetQuicStream(QuicStreamCommand):
self.error_code = error_code
class StopQuicStream(QuicStreamCommand):
class StopSendingQuicStream(QuicStreamCommand):
"""Request termination of the receiving part of a stream."""
error_code: int
@ -769,7 +769,7 @@ class RawQuicLayer(layer.Layer):
if stream_is_client_initiated(
stream_id
) == to_client or not stream_is_unidirectional(stream_id):
yield StopQuicStream(
yield StopSendingQuicStream(
quic_conn, stream_id, QuicErrorCode.NO_ERROR
)
yield from self.close_stream_layer(child_layer, to_client)
@ -866,7 +866,7 @@ class QuicLayer(tunnel.TunnelLayer):
)
elif isinstance(command, ResetQuicStream):
self.quic.reset_stream(command.stream_id, command.error_code)
elif isinstance(command, StopQuicStream):
elif isinstance(command, StopSendingQuicStream):
# the stream might have already been closed, check before stopping
if command.stream_id in self.quic._streams:
self.quic.stop_stream(command.stream_id, command.error_code)

View File

@ -1013,7 +1013,9 @@ class TestClient:
)
<< frame_factory.send_reset(ErrorCode.H3_REQUEST_CANCELLED)
>> frame_factory.receive_data(b"foo")
<< quic.StopQuicStream(tctx.server, 0, ErrorCode.H3_REQUEST_CANCELLED)
<< quic.StopSendingQuicStream(
tctx.server, 0, ErrorCode.H3_REQUEST_CANCELLED
)
) # important: no ResponseData event here!
assert frame_factory.is_done

View File

@ -66,7 +66,7 @@ class TlsEchoLayer(tutils.EchoLayer):
):
yield quic.CloseQuicConnection(event.connection, 123, None, "error")
elif isinstance(event, events.DataReceived) and event.data == b"stop-stream":
yield quic.StopQuicStream(event.connection, 24, 123)
yield quic.StopSendingQuicStream(event.connection, 24, 123)
elif (
isinstance(event, events.DataReceived) and event.data == b"invalid-command"
):
@ -455,7 +455,7 @@ class TestRawQuicLayer:
>> tutils.reply_next_layer(lambda ctx: udp.UDPLayer(ctx, ignore=True))
<< quic.SendQuicStreamData(tctx.server, 0, b"msg1", end_stream=False)
<< quic.SendQuicStreamData(tctx.server, 0, b"", end_stream=True)
<< quic.StopQuicStream(tctx.server, 0, 0)
<< quic.StopSendingQuicStream(tctx.server, 0, 0)
)
def test_open_connection(self, tctx: context.Context):