Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Commit

Permalink
Add test function for length of the HTTP/1.1 response-body.
Browse files Browse the repository at this point in the history
  • Loading branch information
johejo committed Nov 11, 2017
1 parent 5579103 commit cff5c3f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test_release.py
Expand Up @@ -168,3 +168,27 @@ def test_hitting_nghttp2_org_via_h2c_upgrade(self):
assert response.status == 200
assert response.read()
assert response.version == HTTPVersion.http20

def test_http11_response_body_length(self):
"""
This test function uses check the expected length of the HTTP/1.1-response-body.
"""
c = HTTP11Connection('httpbin.org:443')

# Make some HTTP/1.1 requests.
methods = ['GET', 'HEAD']
for method in methods:
c.request(method, '/')
resp = c.get_response()

# Check the expected length of the body.
if method == 'HEAD':
assert resp._length == 0
assert resp.read() == b''
else:
try:
content_length = int(resp.headers[b'Content-Length'][0])
except KeyError:
continue
assert resp._length == content_length
assert resp.read()

0 comments on commit cff5c3f

Please sign in to comment.