avoid exception sending error to client

this is a slightly different approach to
https://github.com/internetarchive/warcprox/pull/121
This commit is contained in:
Noah Levitt 2019-04-09 21:16:45 +00:00
parent 2ca84ae023
commit 7560c0946d

View File

@ -415,9 +415,13 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
try:
return http_server.BaseHTTPRequestHandler.send_error(
self, code, message, explain)
except:
self.logger.error(
'send_error(%r, %r, %r) raised exception', exc_info=True)
except Exception as e:
level = logging.ERROR
if isinstance(e, OSError) and e.errno == 9:
level = logging.TRACE
self.logger.log(
level, 'send_error(%r, %r, %r) raised exception',
exc_info=True)
return None
def _proxy_request(self, extra_response_headers={}):