MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_upstream_error

Function test_upstream_error

test/mitmproxy/proxy/layers/http/test_http2.py:269–300  ·  view source on GitHub ↗
(tctx)

Source from the content-addressed store, hash-verified

267
268
269def test_upstream_error(tctx):
270 playbook, cff = start_h2_client(tctx)
271 flow = Placeholder(HTTPFlow)
272 server = Placeholder(Server)
273 err = Placeholder(bytes)
274 assert (
275 playbook
276 >> DataReceived(
277 tctx.client,
278 cff.build_headers_frame(
279 example_request_headers, flags=["END_STREAM"]
280 ).serialize(),
281 )
282 << http.HttpRequestHeadersHook(flow)
283 >> reply()
284 << http.HttpRequestHook(flow)
285 >> reply()
286 << OpenConnection(server)
287 >> reply("oops server <> error")
288 << http.HttpErrorHook(flow)
289 >> reply()
290 << SendData(tctx.client, err)
291 )
292 frames = decode_frames(err())
293 assert [type(x) for x in frames] == [
294 hyperframe.frame.HeadersFrame,
295 hyperframe.frame.DataFrame,
296 ]
297 d = frames[1]
298 assert isinstance(d, hyperframe.frame.DataFrame)
299 assert b"502 Bad Gateway" in d.data
300 assert b"server &lt;&gt; error" in d.data
301
302
303@pytest.mark.parametrize("trailers", ["trailers", ""])

Callers

nothing calls this directly

Calls 9

PlaceholderFunction · 0.90
DataReceivedClass · 0.90
replyClass · 0.90
OpenConnectionClass · 0.90
SendDataClass · 0.90
start_h2_clientFunction · 0.85
decode_framesFunction · 0.85
build_headers_frameMethod · 0.80
errFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…