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

Function test_max_concurrency

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

Source from the content-addressed store, hash-verified

909
910
911def test_max_concurrency(tctx):
912 playbook, cff = start_h2_client(tctx)
913 server = Placeholder(Server)
914 req1_bytes = Placeholder(bytes)
915 settings_ack_bytes = Placeholder(bytes)
916 req2_bytes = Placeholder(bytes)
917 playbook.hooks = False
918 sff = FrameFactory()
919
920 assert (
921 playbook
922 >> DataReceived(
923 tctx.client,
924 cff.build_headers_frame(
925 example_request_headers, flags=["END_STREAM"], stream_id=1
926 ).serialize(),
927 )
928 << OpenConnection(server)
929 >> reply(None, side_effect=make_h2)
930 << SendData(server, req1_bytes)
931 >> DataReceived(
932 server,
933 sff.build_settings_frame(
934 {h2.settings.SettingCodes.MAX_CONCURRENT_STREAMS: 1}
935 ).serialize(),
936 )
937 << SendData(server, settings_ack_bytes)
938 >> DataReceived(
939 tctx.client,
940 cff.build_headers_frame(
941 example_request_headers, flags=["END_STREAM"], stream_id=3
942 ).serialize(),
943 )
944 # Can't send it upstream yet, all streams in use!
945 >> DataReceived(
946 server,
947 sff.build_headers_frame(
948 example_response_headers, flags=["END_STREAM"], stream_id=1
949 ).serialize(),
950 )
951 # But now we can!
952 << SendData(server, req2_bytes)
953 << SendData(tctx.client, Placeholder(bytes))
954 >> DataReceived(
955 server,
956 sff.build_headers_frame(
957 example_response_headers, flags=["END_STREAM"], stream_id=3
958 ).serialize(),
959 )
960 << SendData(tctx.client, Placeholder(bytes))
961 )
962 settings, _, req1 = decode_frames(req1_bytes())
963 (settings_ack,) = decode_frames(settings_ack_bytes())
964 (req2,) = decode_frames(req2_bytes())
965
966 assert type(settings) is hyperframe.frame.SettingsFrame
967 assert type(req1) is hyperframe.frame.HeadersFrame
968 assert type(settings_ack) is hyperframe.frame.SettingsFrame

Callers

nothing calls this directly

Calls 10

build_headers_frameMethod · 0.95
build_settings_frameMethod · 0.95
PlaceholderFunction · 0.90
FrameFactoryClass · 0.90
DataReceivedClass · 0.90
OpenConnectionClass · 0.90
replyClass · 0.90
SendDataClass · 0.90
start_h2_clientFunction · 0.85
decode_framesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…