mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
http: catch all exceptions
This commit is contained in:
parent
a9f64c22f8
commit
6a239526e5
@ -318,6 +318,11 @@ class HttpLayer(Layer):
|
|||||||
# Make sure that the incoming request matches our expectations
|
# Make sure that the incoming request matches our expectations
|
||||||
self.validate_request(request)
|
self.validate_request(request)
|
||||||
|
|
||||||
|
# Regular Proxy Mode: Handle CONNECT
|
||||||
|
if self.mode == "regular" and request.form_in == "authority":
|
||||||
|
self.handle_regular_mode_connect(request)
|
||||||
|
return
|
||||||
|
|
||||||
except HttpReadDisconnect:
|
except HttpReadDisconnect:
|
||||||
# don't throw an error for disconnects that happen before/between requests.
|
# don't throw an error for disconnects that happen before/between requests.
|
||||||
return
|
return
|
||||||
@ -327,12 +332,6 @@ class HttpLayer(Layer):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
flow = HTTPFlow(self.client_conn, self.server_conn, live=self)
|
flow = HTTPFlow(self.client_conn, self.server_conn, live=self)
|
||||||
|
|
||||||
# Regular Proxy Mode: Handle CONNECT
|
|
||||||
if self.mode == "regular" and request.form_in == "authority":
|
|
||||||
self.handle_regular_mode_connect(request)
|
|
||||||
return
|
|
||||||
|
|
||||||
flow.request = request
|
flow.request = request
|
||||||
self.process_request_hook(flow)
|
self.process_request_hook(flow)
|
||||||
|
|
||||||
@ -368,7 +367,7 @@ class HttpLayer(Layer):
|
|||||||
self.handle_upstream_mode_connect(flow.request.copy())
|
self.handle_upstream_mode_connect(flow.request.copy())
|
||||||
return
|
return
|
||||||
|
|
||||||
except NetlibException as e:
|
except (ProtocolException, NetlibException) as e:
|
||||||
self.send_error_response(502, repr(e))
|
self.send_error_response(502, repr(e))
|
||||||
|
|
||||||
if not flow.response:
|
if not flow.response:
|
||||||
|
Loading…
Reference in New Issue
Block a user