Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
_events.py71 linesDownload Raw Back to quic
1from __future__ import annotations2 3from dataclasses import dataclass4 5from mitmproxy import connection6from mitmproxy.proxy import events7 8 9@dataclass10class QuicStreamEvent(events.ConnectionEvent):11    """Base class for all QUIC stream events."""12 13    stream_id: int14    """The ID of the stream the event was fired for."""15 16 17@dataclass18class QuicStreamDataReceived(QuicStreamEvent):19    """Event that is fired whenever data is received on a stream."""20 21    data: bytes22    """The data which was received."""23    end_stream: bool24    """Whether the STREAM frame had the FIN bit set."""25 26    def __repr__(self):27        target = repr(self.connection).partition("(")[0].lower()28        end_stream = "[end_stream] " if self.end_stream else ""29        return f"QuicStreamDataReceived({target} on {self.stream_id}, {end_stream}{self.data!r})"30 31 32@dataclass33class QuicStreamReset(QuicStreamEvent):34    """Event that is fired when the remote peer resets a stream."""35 36    error_code: int37    """The error code that triggered the reset."""38 39 40@dataclass41class QuicStreamStopSending(QuicStreamEvent):42    """Event that is fired when the remote peer sends a STOP_SENDING frame."""43 44    error_code: int45    """The application protocol error code."""46 47 48class QuicConnectionClosed(events.ConnectionClosed):49    """QUIC connection has been closed."""50 51    error_code: int52    "The error code which was specified when closing the connection."53 54    frame_type: int | None55    "The frame type which caused the connection to be closed, or `None`."56 57    reason_phrase: str58    "The human-readable reason for which the connection was closed."59 60    def __init__(61        self,62        conn: connection.Connection,63        error_code: int,64        frame_type: int | None,65        reason_phrase: str,66    ) -> None:67        super().__init__(conn)68        self.error_code = error_code69        self.frame_type = frame_type70        self.reason_phrase = reason_phrase71 
codekingpro/portable-devtools · Team Ai