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

Method flow_done

mitmproxy/proxy/layers/http/__init__.py:537–566  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

535 yield from self.flow_done()
536
537 def flow_done(self) -> layer.CommandGenerator[None]:
538 if not self.flow.websocket:
539 self.flow.live = False
540
541 assert self.flow.response
542 if self.flow.response.status_code == 101:
543 if self.flow.websocket:
544 self.child_layer = websocket.WebsocketLayer(self.context, self.flow)
545 elif self.context.options.rawtcp:
546 self.child_layer = tcp.TCPLayer(self.context)
547 else:
548 yield commands.Log(
549 f"Sent HTTP 101 response, but no protocol is enabled to upgrade to.",
550 WARNING,
551 )
552 yield commands.CloseConnection(self.context.client)
553 self.client_state = self.server_state = self.state_errored
554 return
555 if self.debug:
556 yield commands.Log(
557 f"{self.debug}[http] upgrading to {self.child_layer}", DEBUG
558 )
559 self._handle_event = self.passthrough
560 yield from self.child_layer.handle_event(events.Start())
561 else:
562 yield DropStream(self.stream_id)
563
564 # delay sending EOM until the child layer is set up,
565 # we may get data immediately and need to be prepared to handle it.
566 yield SendHttp(ResponseEndOfMessage(self.stream_id), self.context.client)
567
568 def check_body_size(self, request: bool) -> layer.CommandGenerator[bool]:
569 """

Callers 2

send_responseMethod · 0.95

Calls 4

DropStreamClass · 0.85
SendHttpClass · 0.85
handle_eventMethod · 0.45

Tested by

no test coverage detected