MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_request_trailers

Function test_request_trailers

test/mitmproxy/proxy/layers/http/test_http2.py:225–266  ·  view source on GitHub ↗
(tctx: Context, open_h2_server_conn: Server, stream)

Source from the content-addressed store, hash-verified

223
224@pytest.mark.parametrize("stream", ["stream", ""])
225def test_request_trailers(tctx: Context, open_h2_server_conn: Server, stream):
226 playbook, cff = start_h2_client(tctx)
227 tctx.server = open_h2_server_conn
228
229 def enable_streaming(flow: HTTPFlow):
230 flow.request.stream = bool(stream)
231
232 flow = Placeholder(HTTPFlow)
233 server_data1 = Placeholder(bytes)
234 server_data2 = Placeholder(bytes)
235 (
236 playbook
237 >> DataReceived(
238 tctx.client,
239 cff.build_headers_frame(example_request_headers).serialize()
240 + cff.build_data_frame(b"Hello, World!").serialize(),
241 )
242 << http.HttpRequestHeadersHook(flow)
243 >> reply(side_effect=enable_streaming)
244 )
245 if stream:
246 playbook << SendData(tctx.server, server_data1)
247 assert (
248 playbook
249 >> DataReceived(
250 tctx.client,
251 cff.build_headers_frame(
252 example_request_trailers, flags=["END_STREAM"]
253 ).serialize(),
254 )
255 << http.HttpRequestHook(flow)
256 >> reply()
257 << SendData(tctx.server, server_data2)
258 )
259 frames = decode_frames(server_data1.setdefault(b"") + server_data2())
260 assert [type(x) for x in frames] == [
261 hyperframe.frame.SettingsFrame,
262 hyperframe.frame.WindowUpdateFrame,
263 hyperframe.frame.HeadersFrame,
264 hyperframe.frame.DataFrame,
265 hyperframe.frame.HeadersFrame,
266 ]
267
268
269def test_upstream_error(tctx):

Callers

nothing calls this directly

Calls 9

PlaceholderFunction · 0.90
DataReceivedClass · 0.90
replyClass · 0.90
SendDataClass · 0.90
start_h2_clientFunction · 0.85
decode_framesFunction · 0.85
build_headers_frameMethod · 0.80
build_data_frameMethod · 0.80
setdefaultMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…