mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
work around odd problem (see comment in code)
This commit is contained in:
parent
7f1c7f532e
commit
e989b2f667
2
setup.py
2
setup.py
@ -40,7 +40,7 @@ except:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='warcprox',
|
name='warcprox',
|
||||||
version='2.4b2.dev159',
|
version='2.4b2.dev160',
|
||||||
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',
|
||||||
|
@ -390,6 +390,28 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
|||||||
self.send_error(502, str(e))
|
self.send_error(502, str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def send_error(self, code, message=None, explain=None):
|
||||||
|
# BaseHTTPRequestHandler.send_response_only() in http/server.py
|
||||||
|
# does this:
|
||||||
|
# if not hasattr(self, '_headers_buffer'):
|
||||||
|
# self._headers_buffer = []
|
||||||
|
# but we sometimes see self._headers_buffer == None
|
||||||
|
# (This happened before! see commit dc9fdc34125dd2357)
|
||||||
|
# Workaround:
|
||||||
|
if hasattr(self, '_headers_buffer') and not self._headers_buffer:
|
||||||
|
self._headers_buffer = []
|
||||||
|
try:
|
||||||
|
return http_server.BaseHTTPRequestHandler.send_error(
|
||||||
|
self, code, message, explain)
|
||||||
|
except:
|
||||||
|
self.logger.error(
|
||||||
|
'''WTF: self=%r hasattr(self,'_headers_buffer')=%r''',
|
||||||
|
self, hasattr(self,'_headers_buffer'))
|
||||||
|
if hasattr(self,'_headers_buffer'):
|
||||||
|
self.logger.error(
|
||||||
|
'WTF: self._headers_buffer=%r', self._headers_buffer)
|
||||||
|
return None
|
||||||
|
|
||||||
def _proxy_request(self, extra_response_headers={}):
|
def _proxy_request(self, extra_response_headers={}):
|
||||||
'''
|
'''
|
||||||
Sends the request to the remote server, then uses a ProxyingRecorder to
|
Sends the request to the remote server, then uses a ProxyingRecorder to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user