failing test for correct handling of "http.client.RemoteDisconnected: Remote end closed connection without response" from remote server

This commit is contained in:
Noah Levitt 2017-11-22 12:49:46 -08:00
parent b28f9b9fb7
commit 627ef5667b
2 changed files with 16 additions and 1 deletions

View File

@ -51,7 +51,7 @@ except:
setuptools.setup(
name='warcprox',
version='2.2.1b2.dev120',
version='2.2.1b2.dev121',
description='WARC writing MITM HTTP/S proxy',
url='https://github.com/internetarchive/warcprox',
author='Noah Levitt',

View File

@ -237,6 +237,9 @@ class _TestHttpRequestHandler(http_server.BaseHTTPRequestHandler):
raise Exception('bad path')
headers = b'HTTP/1.1 200 OK\r\n' + actual_headers + b'\r\n'
logging.info('headers=%r payload=%r', headers, payload)
elif self.path == '/empty-response':
headers = b''
payload = b''
else:
payload = b'404 Not Found\n'
headers = (b'HTTP/1.1 404 Not Found\r\n'
@ -1643,6 +1646,18 @@ def test_long_warcprox_meta(
with pytest.raises(StopIteration):
next(rec_iter)
def test_empty_response(
warcprox_, http_daemon, https_daemon, archiving_proxies,
playback_proxies):
url = 'http://localhost:%s/empty-response' % http_daemon.server_port
response = requests.get(url, proxies=archiving_proxies, verify=False)
assert response.status_code == 500
url = 'https://localhost:%s/empty-response' % http_daemon.server_port
response = requests.get(url, proxies=archiving_proxies, verify=False)
assert response.status_code == 500
def test_payload_digest(warcprox_, http_daemon):
'''
Tests that digest is of RFC2616 "entity body"