MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_proxy_chain

Function test_proxy_chain

test/mitmproxy/proxy/layers/http/test_http.py:1013–1039  ·  view source on GitHub ↗
(tctx, strategy)

Source from the content-addressed store, hash-verified

1011
1012@pytest.mark.parametrize("strategy", ["eager", "lazy"])
1013def test_proxy_chain(tctx, strategy):
1014 server = Placeholder(Server)
1015 tctx.options.connection_strategy = strategy
1016 playbook = Playbook(http.HttpLayer(tctx, HTTPMode.regular), hooks=False)
1017
1018 playbook >> DataReceived(
1019 tctx.client, b"CONNECT proxy:8080 HTTP/1.1\r\nHost: proxy:8080\r\n\r\n"
1020 )
1021 if strategy == "eager":
1022 playbook << OpenConnection(server)
1023 playbook >> reply(None)
1024 playbook << SendData(tctx.client, b"HTTP/1.1 200 Connection established\r\n\r\n")
1025
1026 playbook >> DataReceived(
1027 tctx.client, b"CONNECT second-proxy:8080 HTTP/1.1\r\nHost: proxy:8080\r\n\r\n"
1028 )
1029 playbook << layer.NextLayerHook(Placeholder())
1030 playbook >> reply_next_layer(lambda ctx: http.HttpLayer(ctx, HTTPMode.transparent))
1031 playbook << SendData(
1032 tctx.client,
1033 BytesMatching(
1034 b"mitmproxy received an HTTP CONNECT request even though it is not running in regular/upstream mode."
1035 ),
1036 )
1037 playbook << CloseConnection(tctx.client)
1038
1039 assert playbook
1040
1041
1042def test_no_headers(tctx):

Callers

nothing calls this directly

Calls 9

PlaceholderFunction · 0.90
PlaybookClass · 0.90
DataReceivedClass · 0.90
OpenConnectionClass · 0.90
replyClass · 0.90
SendDataClass · 0.90
reply_next_layerFunction · 0.90
BytesMatchingFunction · 0.90
CloseConnectionClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…