MCPcopy
hub / github.com/mitmproxy/mitmproxy / Context

Class Context

mitmproxy/proxy/context.py:10–58  ·  view source on GitHub ↗

The context object provided to each protocol layer in the proxy core.

Source from the content-addressed store, hash-verified

8
9
10class 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 )

Callers 10

test_upstream_httpsFunction · 0.90
test_reprsFunction · 0.90
test_next_layerMethod · 0.90
test_next_layerFunction · 0.90
__init__Method · 0.90
__init__Method · 0.90
forkMethod · 0.85

Calls

no outgoing calls

Tested by 6

test_upstream_httpsFunction · 0.72
test_reprsFunction · 0.72
test_next_layerMethod · 0.72
test_next_layerFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…