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

Method check_killed

mitmproxy/proxy/layers/http/__init__.py:696–721  ·  view source on GitHub ↗
(self, emit_error_hook: bool)

Source from the content-addressed store, hash-verified

694 return False
695
696 def check_killed(self, emit_error_hook: bool) -> layer.CommandGenerator[bool]:
697 killed_by_us = (
698 self.flow.error and self.flow.error.msg == flow.Error.KILLED_MESSAGE
699 )
700 # The client may have closed the connection while we were waiting for the hook to complete.
701 # We peek into the event queue to see if that is the case.
702 killed_by_remote = None
703 for evt in self._paused_event_queue:
704 if isinstance(evt, RequestProtocolError):
705 killed_by_remote = evt.message
706 break
707
708 if killed_by_remote:
709 if not self.flow.error:
710 self.flow.error = flow.Error(killed_by_remote)
711 if killed_by_us or killed_by_remote:
712 if emit_error_hook:
713 yield HttpErrorHook(self.flow)
714 yield SendHttp(
715 ResponseProtocolError(self.stream_id, "killed", ErrorCode.KILL),
716 self.context.client,
717 )
718 self.flow.live = False
719 self.client_state = self.server_state = self.state_errored
720 return True
721 return False
722
723 def handle_protocol_error(
724 self, event: RequestProtocolError | ResponseProtocolError

Callers 6

send_responseMethod · 0.95
handle_protocol_errorMethod · 0.95
handle_connectMethod · 0.95

Calls 3

HttpErrorHookClass · 0.85
SendHttpClass · 0.85

Tested by

no test coverage detected