MCPcopy
hub / github.com/mitmproxy/mitmproxy / WebSocketData

Class WebSocketData

mitmproxy/websocket.py:155–182  ·  view source on GitHub ↗

A data container for everything related to a single WebSocket connection. This is typically accessed as `mitmproxy.http.HTTPFlow.websocket`.

Source from the content-addressed store, hash-verified

153
154@dataclass
155class WebSocketData(serializable.SerializableDataclass):
156 """
157 A data container for everything related to a single WebSocket connection.
158 This is typically accessed as `mitmproxy.http.HTTPFlow.websocket`.
159 """
160
161 messages: list[WebSocketMessage] = field(default_factory=list)
162 """All `WebSocketMessage`s transferred over this connection."""
163
164 closed_by_client: bool | None = None
165 """
166 `True` if the client closed the connection,
167 `False` if the server closed the connection,
168 `None` if the connection is active.
169 """
170 close_code: int | None = None
171 """[Close Code](https://tools.ietf.org/html/rfc6455#section-7.1.5)"""
172 close_reason: str | None = None
173 """[Close Reason](https://tools.ietf.org/html/rfc6455#section-7.1.6)"""
174
175 timestamp_end: float | None = None
176 """*Timestamp:* WebSocket connection closed."""
177
178 def __repr__(self):
179 return f"<WebSocketData ({len(self.messages)} messages)>"
180
181 def _get_formatted_messages(self) -> bytes:
182 return b"\n".join(m._format_ws_message() for m in self.messages)

Callers 2

ws_testdataFunction · 0.90
send_responseMethod · 0.90

Calls

no outgoing calls

Tested by 1

ws_testdataFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…