mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
move more stuff in do_COMMAND inside the try block so that exceptions result in a 500 response
This commit is contained in:
parent
c642565ad8
commit
c87ff90bc1
2
setup.py
2
setup.py
@ -51,7 +51,7 @@ except:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='warcprox',
|
name='warcprox',
|
||||||
version='2.1b1.dev76',
|
version='2.1b1.dev77',
|
||||||
description='WARC writing MITM HTTP/S proxy',
|
description='WARC writing MITM HTTP/S proxy',
|
||||||
url='https://github.com/internetarchive/warcprox',
|
url='https://github.com/internetarchive/warcprox',
|
||||||
author='Noah Levitt',
|
author='Noah Levitt',
|
||||||
|
@ -292,7 +292,8 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
|||||||
self._transition_to_ssl()
|
self._transition_to_ssl()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
try:
|
try:
|
||||||
self.logger.error("problem handling {}: {}".format(repr(self.requestline), e))
|
self.logger.error(
|
||||||
|
"problem handling %s: %s", repr(self.requestline), e)
|
||||||
if type(e) is socket.timeout:
|
if type(e) is socket.timeout:
|
||||||
self.send_error(504, str(e))
|
self.send_error(504, str(e))
|
||||||
else:
|
else:
|
||||||
@ -328,13 +329,13 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
|||||||
self.logger.trace(
|
self.logger.trace(
|
||||||
'request from %s:%s: %s', self.client_address[0],
|
'request from %s:%s: %s', self.client_address[0],
|
||||||
self.client_address[1], self.requestline)
|
self.client_address[1], self.requestline)
|
||||||
if self.is_connect:
|
|
||||||
self.url = self._construct_tunneled_url()
|
|
||||||
else:
|
|
||||||
self._determine_host_port()
|
|
||||||
assert self.url
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if self.is_connect:
|
||||||
|
self.url = self._construct_tunneled_url()
|
||||||
|
else:
|
||||||
|
self._determine_host_port()
|
||||||
|
assert self.url
|
||||||
|
|
||||||
# Connect to destination
|
# Connect to destination
|
||||||
self._connect_to_remote_server()
|
self._connect_to_remote_server()
|
||||||
except warcprox.RequestBlockedByRule as e:
|
except warcprox.RequestBlockedByRule as e:
|
||||||
@ -342,7 +343,9 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
|||||||
self.logger.info("%s: %s", repr(self.requestline), e)
|
self.logger.info("%s: %s", repr(self.requestline), e)
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error("problem processing request {}: {}".format(repr(self.requestline), e), exc_info=True)
|
self.logger.error(
|
||||||
|
"problem processing request %s: %s",
|
||||||
|
repr(self.requestline), e, exc_info=True)
|
||||||
self.send_error(500, str(e))
|
self.send_error(500, str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user