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(
|
||||
name='warcprox',
|
||||
version='2.2.1b2.dev121',
|
||||
version='2.2.1b2.dev122',
|
||||
description='WARC writing MITM HTTP/S proxy',
|
||||
url='https://github.com/internetarchive/warcprox',
|
||||
author='Noah Levitt',
|
||||
|
@ -1652,11 +1652,13 @@ def test_empty_response(
|
||||
|
||||
url = 'http://localhost:%s/empty-response' % http_daemon.server_port
|
||||
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)
|
||||
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):
|
||||
'''
|
||||
|
@ -363,9 +363,12 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
||||
|
||||
try:
|
||||
return self._proxy_request()
|
||||
except:
|
||||
self.logger.error("exception proxying request", exc_info=True)
|
||||
raise
|
||||
except Exception as e:
|
||||
self.logger.error(
|
||||
'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={}):
|
||||
'''
|
||||
@ -425,10 +428,6 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
||||
buf = prox_rec_res.read(65536)
|
||||
|
||||
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:
|
||||
# Let's close off the remote end
|
||||
if prox_rec_res:
|
||||
|
Loading…
x
Reference in New Issue
Block a user