A data container for everything related to a single WebSocket connection. This is typically accessed as `mitmproxy.http.HTTPFlow.websocket`.
| 153 | |
| 154 | @dataclass |
| 155 | class 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) |
no outgoing calls
searching dependent graphs…