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

Commit cff5c3f

Browse files
committed
Add test function for length of the HTTP/1.1 response-body.
1 parent 5579103 commit cff5c3f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Diff for: test_release.py

+24
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,27 @@ def test_hitting_nghttp2_org_via_h2c_upgrade(self):
168168
assert response.status == 200
169169
assert response.read()
170170
assert response.version == HTTPVersion.http20
171+
172+
def test_http11_response_body_length(self):
173+
"""
174+
This test function uses check the expected length of the HTTP/1.1-response-body.
175+
"""
176+
c = HTTP11Connection('httpbin.org:443')
177+
178+
# Make some HTTP/1.1 requests.
179+
methods = ['GET', 'HEAD']
180+
for method in methods:
181+
c.request(method, '/')
182+
resp = c.get_response()
183+
184+
# Check the expected length of the body.
185+
if method == 'HEAD':
186+
assert resp._length == 0
187+
assert resp.read() == b''
188+
else:
189+
try:
190+
content_length = int(resp.headers[b'Content-Length'][0])
191+
except KeyError:
192+
continue
193+
assert resp._length == content_length
194+
assert resp.read()

0 commit comments

Comments
 (0)