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

Method http_status_code

mitmproxy/proxy/layers/http/_events.py:100–127  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

98 RESPONSE_VALIDATION_FAILED = 13
99
100 def http_status_code(self) -> int | None:
101 match self:
102 # Client Errors
103 case (
104 ErrorCode.GENERIC_CLIENT_ERROR
105 | ErrorCode.REQUEST_VALIDATION_FAILED
106 | ErrorCode.DESTINATION_UNKNOWN
107 ):
108 return status_codes.BAD_REQUEST
109 case ErrorCode.REQUEST_TOO_LARGE:
110 return status_codes.PAYLOAD_TOO_LARGE
111 case (
112 ErrorCode.CONNECT_FAILED
113 | ErrorCode.GENERIC_SERVER_ERROR
114 | ErrorCode.RESPONSE_VALIDATION_FAILED
115 | ErrorCode.RESPONSE_TOO_LARGE
116 ):
117 return status_codes.BAD_GATEWAY
118 case (
119 ErrorCode.PASSTHROUGH_CLOSE
120 | ErrorCode.KILL
121 | ErrorCode.HTTP_1_1_REQUIRED
122 | ErrorCode.CLIENT_DISCONNECTED
123 | ErrorCode.CANCEL
124 ):
125 return None
126 case other: # pragma: no cover
127 typing.assert_never(other)
128
129
130@dataclass

Callers 3

_handle_eventMethod · 0.80
_handle_eventMethod · 0.80
sendMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected