MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / wait

Method wait

mitmproxy/proxy/layers/http/_http1.py:125–147  ·  view source on GitHub ↗

We wait for the current flow to be finished before parsing the next message, as we may want to upgrade to WebSocket or plain TCP before that.

(self, event: events.Event)

Source from the content-addressed store, hash-verified

123 return
124
125 def wait(self, event: events.Event) -> layer.CommandGenerator[None]:
126 """
127 We wait for the current flow to be finished before parsing the next message,
128 as we may want to upgrade to WebSocket or plain TCP before that.
129 """
130 assert self.stream_id
131 if isinstance(event, events.DataReceived):
132 return
133 elif isinstance(event, events.ConnectionClosed):
134 # for practical purposes, we assume that a peer which sent at least a FIN
135 # is not interested in any more data from us, see
136 # see https://github.com/httpwg/http-core/issues/22
137 if event.connection.state is not ConnectionState.CLOSED:
138 yield commands.CloseConnection(event.connection)
139 yield ReceiveHttp(
140 self.ReceiveProtocolError(
141 self.stream_id,
142 f"Client disconnected.",
143 code=ErrorCode.CLIENT_DISCONNECTED,
144 )
145 )
146 else: # pragma: no cover
147 raise AssertionError(f"Unexpected event: {event}")
148
149 def done(self, event: events.ConnectionEvent) -> layer.CommandGenerator[None]:
150 yield from () # pragma: no cover

Callers 12

test_readMethod · 0.80
wait_for_resumeMethod · 0.80
runMethod · 0.80
watchMethod · 0.80
handle_clientMethod · 0.80
handle_connectionMethod · 0.80
receiveFunction · 0.80
replayMethod · 0.80
handle_hookMethod · 0.80
end_recordingMethod · 0.80
wrap_honeyproxyMethod · 0.80

Calls 1

ReceiveHttpClass · 0.90

Tested by 2

test_readMethod · 0.64