mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
fix #811
This commit is contained in:
parent
8e9cd77b55
commit
978eb17d66
@ -1,12 +1,11 @@
|
|||||||
from __future__ import (absolute_import, print_function, division)
|
from __future__ import (absolute_import, print_function, division)
|
||||||
import itertools
|
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from netlib import tcp
|
from netlib import tcp
|
||||||
from netlib.exceptions import HttpException, HttpReadDisconnect, TcpException
|
from netlib.exceptions import HttpException, HttpReadDisconnect, NetlibException
|
||||||
from netlib.http import http1, Headers
|
from netlib.http import http1, Headers
|
||||||
from netlib.http import CONTENT_MISSING
|
from netlib.http import CONTENT_MISSING
|
||||||
from netlib.tcp import Address
|
from netlib.tcp import Address
|
||||||
@ -319,7 +318,7 @@ class HttpLayer(Layer):
|
|||||||
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
|
||||||
except (HttpException, TcpException) as e:
|
except NetlibException as e:
|
||||||
self.send_error_response(400, repr(e))
|
self.send_error_response(400, repr(e))
|
||||||
six.reraise(ProtocolException, ProtocolException("Error in HTTP connection: %s" % repr(e)), sys.exc_info()[2])
|
six.reraise(ProtocolException, ProtocolException("Error in HTTP connection: %s" % repr(e)), sys.exc_info()[2])
|
||||||
|
|
||||||
@ -366,7 +365,7 @@ class HttpLayer(Layer):
|
|||||||
self.handle_upstream_mode_connect(flow.request.copy())
|
self.handle_upstream_mode_connect(flow.request.copy())
|
||||||
return
|
return
|
||||||
|
|
||||||
except (HttpException, TcpException) as e:
|
except 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:
|
||||||
@ -392,7 +391,7 @@ class HttpLayer(Layer):
|
|||||||
try:
|
try:
|
||||||
response = make_error_response(code, message)
|
response = make_error_response(code, message)
|
||||||
self.send_response(response)
|
self.send_response(response)
|
||||||
except TcpException:
|
except NetlibException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def change_upstream_proxy_server(self, address):
|
def change_upstream_proxy_server(self, address):
|
||||||
@ -440,7 +439,7 @@ class HttpLayer(Layer):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
get_response()
|
get_response()
|
||||||
except (TcpException, HttpException) as v:
|
except NetlibException as v:
|
||||||
self.log(
|
self.log(
|
||||||
"server communication error: %s" % repr(v),
|
"server communication error: %s" % repr(v),
|
||||||
level="debug"
|
level="debug"
|
||||||
|
Loading…
Reference in New Issue
Block a user