Skip to content

Commit b68f60f

Browse files
committed
[qlog] log DATAGRAM and NEW_TOKEN frames earlier
Log the frames before trigger an exception to facilitate diagnostics.
1 parent a4d0ffb commit b68f60f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/aioquic/quic/connection.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,12 @@ def _handle_datagram_frame(
13331333
length = buf.capacity - start
13341334
data = buf.pull_bytes(length)
13351335

1336+
# log frame
1337+
if self._quic_logger is not None:
1338+
context.quic_logger_frames.append(
1339+
self._quic_logger.encode_datagram_frame(length=length)
1340+
)
1341+
13361342
# check frame is allowed
13371343
if (
13381344
self._configuration.max_datagram_frame_size is None
@@ -1346,12 +1352,6 @@ def _handle_datagram_frame(
13461352

13471353
self._events.append(events.DatagramFrameReceived(data=data))
13481354

1349-
# log frame
1350-
if self._quic_logger is not None:
1351-
context.quic_logger_frames.append(
1352-
self._quic_logger.encode_datagram_frame(length=length)
1353-
)
1354-
13551355
def _handle_max_data_frame(
13561356
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
13571357
) -> None:
@@ -1489,19 +1489,19 @@ def _handle_new_token_frame(
14891489
length = buf.pull_uint_var()
14901490
token = buf.pull_bytes(length)
14911491

1492+
# log frame
1493+
if self._quic_logger is not None:
1494+
context.quic_logger_frames.append(
1495+
self._quic_logger.encode_new_token_frame(token=token)
1496+
)
1497+
14921498
if not self._is_client:
14931499
raise QuicConnectionError(
14941500
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
14951501
frame_type=frame_type,
14961502
reason_phrase="Clients must not send NEW_TOKEN frames",
14971503
)
14981504

1499-
# log frame
1500-
if self._quic_logger is not None:
1501-
context.quic_logger_frames.append(
1502-
self._quic_logger.encode_new_token_frame(token=token)
1503-
)
1504-
15051505
def _handle_padding_frame(
15061506
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
15071507
) -> None:

0 commit comments

Comments
 (0)