An HTTPFlow is a collection of objects representing a single HTTP transaction.
| 1208 | |
| 1209 | |
| 1210 | class HTTPFlow(flow.Flow): |
| 1211 | """ |
| 1212 | An HTTPFlow is a collection of objects representing a single HTTP |
| 1213 | transaction. |
| 1214 | """ |
| 1215 | |
| 1216 | request: Request |
| 1217 | """The client's HTTP request.""" |
| 1218 | response: Response | None = None |
| 1219 | """The server's HTTP response.""" |
| 1220 | error: flow.Error | None = None |
| 1221 | """ |
| 1222 | A connection or protocol error affecting this flow. |
| 1223 | |
| 1224 | Note that it's possible for a Flow to have both a response and an error |
| 1225 | object. This might happen, for instance, when a response was received |
| 1226 | from the server, but there was an error sending it back to the client. |
| 1227 | """ |
| 1228 | |
| 1229 | websocket: WebSocketData | None = None |
| 1230 | """ |
| 1231 | If this HTTP flow initiated a WebSocket connection, this attribute contains all associated WebSocket data. |
| 1232 | """ |
| 1233 | |
| 1234 | def get_state(self) -> serializable.State: |
| 1235 | return { |
| 1236 | **super().get_state(), |
| 1237 | "request": self.request.get_state(), |
| 1238 | "response": self.response.get_state() if self.response else None, |
| 1239 | "websocket": self.websocket.get_state() if self.websocket else None, |
| 1240 | } |
| 1241 | |
| 1242 | def set_state(self, state: serializable.State) -> None: |
| 1243 | self.request = Request.from_state(state.pop("request")) |
| 1244 | self.response = Response.from_state(r) if (r := state.pop("response")) else None |
| 1245 | self.websocket = ( |
| 1246 | WebSocketData.from_state(w) if (w := state.pop("websocket")) else None |
| 1247 | ) |
| 1248 | super().set_state(state) |
| 1249 | |
| 1250 | def __repr__(self): |
| 1251 | s = "<HTTPFlow" |
| 1252 | for a in ( |
| 1253 | "request", |
| 1254 | "response", |
| 1255 | "websocket", |
| 1256 | "error", |
| 1257 | "client_conn", |
| 1258 | "server_conn", |
| 1259 | ): |
| 1260 | if getattr(self, a, False): |
| 1261 | s += f"\r\n {a} = {{flow.{a}}}" |
| 1262 | s += ">" |
| 1263 | return s.format(flow=self) |
| 1264 | |
| 1265 | @property |
| 1266 | def timestamp_start(self) -> float: |
| 1267 | """*Read-only:* An alias for `Request.timestamp_start`.""" |
no outgoing calls
searching dependent graphs…