MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / test_simple

Method test_simple

test/mitmproxy/proxy/layers/http/test_http1.py:117–145  ·  view source on GitHub ↗
(self, tctx, pipeline)

Source from the content-addressed store, hash-verified

115class TestClient:
116 @pytest.mark.parametrize("pipeline", ["pipeline", None])
117 def test_simple(self, tctx, pipeline):
118 req = http.Request.make("GET", "http://example.com/")
119 resp = Placeholder(ResponseHeaders)
120
121 playbook = Playbook(Http1Client(tctx))
122 (
123 playbook
124 >> RequestHeaders(1, req, True)
125 << SendData(tctx.server, b"GET / HTTP/1.1\r\ncontent-length: 0\r\n\r\n")
126 >> RequestEndOfMessage(1)
127 )
128 if pipeline:
129 with pytest.raises(
130 AssertionError, match="assert self.stream_id == event.stream_id"
131 ):
132 assert playbook >> RequestHeaders(3, req, True)
133 return
134 assert (
135 playbook
136 >> DataReceived(
137 tctx.server, b"HTTP/1.1 200 OK\r\ncontent-length: 0\r\n\r\n"
138 )
139 << ReceiveHttp(resp)
140 << ReceiveHttp(ResponseEndOfMessage(1))
141 # no we can send the next request
142 >> RequestHeaders(3, req, True)
143 << SendData(tctx.server, b"GET / HTTP/1.1\r\ncontent-length: 0\r\n\r\n")
144 )
145 assert resp().response.status_code == 200
146
147 def test_connect(self, tctx):
148 req = http.Request.make("CONNECT", "http://example.com:443")

Callers

nothing calls this directly

Calls 10

PlaceholderFunction · 0.90
PlaybookClass · 0.90
Http1ClientClass · 0.90
RequestHeadersClass · 0.90
SendDataClass · 0.90
RequestEndOfMessageClass · 0.90
DataReceivedClass · 0.90
ReceiveHttpClass · 0.90
makeMethod · 0.45

Tested by

no test coverage detected