The context object provided to each protocol layer in the proxy core.
| 8 | |
| 9 | |
| 10 | class Context: |
| 11 | """ |
| 12 | The context object provided to each protocol layer in the proxy core. |
| 13 | """ |
| 14 | |
| 15 | client: connection.Client |
| 16 | """The client connection.""" |
| 17 | server: connection.Server |
| 18 | """ |
| 19 | The server connection. |
| 20 | |
| 21 | For practical reasons this attribute is always set, even if there is not server connection yet. |
| 22 | In this case the server address is `None`. |
| 23 | """ |
| 24 | options: Options |
| 25 | """ |
| 26 | Provides access to options for proxy layers. Not intended for use by addons, use `mitmproxy.ctx.options` instead. |
| 27 | """ |
| 28 | layers: list["mitmproxy.proxy.layer.Layer"] |
| 29 | """ |
| 30 | The protocol layer stack. |
| 31 | """ |
| 32 | |
| 33 | def __init__( |
| 34 | self, |
| 35 | client: connection.Client, |
| 36 | options: Options, |
| 37 | ) -> None: |
| 38 | self.client = client |
| 39 | self.options = options |
| 40 | self.server = connection.Server( |
| 41 | address=None, transport_protocol=client.transport_protocol |
| 42 | ) |
| 43 | self.layers = [] |
| 44 | |
| 45 | def fork(self) -> "Context": |
| 46 | ret = Context(self.client, self.options) |
| 47 | ret.server = self.server |
| 48 | ret.layers = self.layers.copy() |
| 49 | return ret |
| 50 | |
| 51 | def __repr__(self): |
| 52 | return ( |
| 53 | f"Context(\n" |
| 54 | f" {self.client!r},\n" |
| 55 | f" {self.server!r},\n" |
| 56 | f" layers=[{self.layers!r}]\n" |
| 57 | f")" |
| 58 | ) |
no outgoing calls
searching dependent graphs…