mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
fix failing test, and change response code from 500 to more appropriate 502
This commit is contained in:
parent
627ef5667b
commit
5be289730f
2
setup.py
2
setup.py
@ -51,7 +51,7 @@ except:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='warcprox',
|
name='warcprox',
|
||||||
version='2.2.1b2.dev121',
|
version='2.2.1b2.dev122',
|
||||||
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',
|
||||||
|
@ -1652,11 +1652,13 @@ def test_empty_response(
|
|||||||
|
|
||||||
url = 'http://localhost:%s/empty-response' % http_daemon.server_port
|
url = 'http://localhost:%s/empty-response' % http_daemon.server_port
|
||||||
response = requests.get(url, proxies=archiving_proxies, verify=False)
|
response = requests.get(url, proxies=archiving_proxies, verify=False)
|
||||||
assert response.status_code == 500
|
assert response.status_code == 502
|
||||||
|
assert response.reason == 'Remote end closed connection without response'
|
||||||
|
|
||||||
url = 'https://localhost:%s/empty-response' % http_daemon.server_port
|
url = 'https://localhost:%s/empty-response' % https_daemon.server_port
|
||||||
response = requests.get(url, proxies=archiving_proxies, verify=False)
|
response = requests.get(url, proxies=archiving_proxies, verify=False)
|
||||||
assert response.status_code == 500
|
assert response.status_code == 502
|
||||||
|
assert response.reason == 'Remote end closed connection without response'
|
||||||
|
|
||||||
def test_payload_digest(warcprox_, http_daemon):
|
def test_payload_digest(warcprox_, http_daemon):
|
||||||
'''
|
'''
|
||||||
|
@ -363,9 +363,12 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
return self._proxy_request()
|
return self._proxy_request()
|
||||||
except:
|
except Exception as e:
|
||||||
self.logger.error("exception proxying request", exc_info=True)
|
self.logger.error(
|
||||||
raise
|
'error from remote server(?) %r: %r',
|
||||||
|
self.requestline, e, exc_info=True)
|
||||||
|
self.send_error(502, str(e))
|
||||||
|
return
|
||||||
|
|
||||||
def _proxy_request(self, extra_response_headers={}):
|
def _proxy_request(self, extra_response_headers={}):
|
||||||
'''
|
'''
|
||||||
@ -425,10 +428,6 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
|||||||
buf = prox_rec_res.read(65536)
|
buf = prox_rec_res.read(65536)
|
||||||
|
|
||||||
self.log_request(prox_rec_res.status, prox_rec_res.recorder.len)
|
self.log_request(prox_rec_res.status, prox_rec_res.recorder.len)
|
||||||
except Exception as e:
|
|
||||||
self.logger.error(
|
|
||||||
"%r proxying %s %s", e, self.command, self.url,
|
|
||||||
exc_info=True)
|
|
||||||
finally:
|
finally:
|
||||||
# Let's close off the remote end
|
# Let's close off the remote end
|
||||||
if prox_rec_res:
|
if prox_rec_res:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user