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

Commit 9fa200a

Browse files
committed
fix HTTP/1.1 response body length
1 parent a3dd27b commit 9fa200a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

hyper/http11/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(self, code, reason, headers, sock, connection=None,
6363

6464
# Whether we expect a chunked response.
6565
self._chunked = (
66-
b'chunked' in self.headers.get(b'transfer-encoding', [])
66+
b'chunked' in self.headers.get(b'transfer-encoding', [])
6767
)
6868

6969
# When content-length is absent and response is not chunked,

test/test_http11.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,18 @@ def test_response_version(self):
941941
r = HTTP11Response(200, 'OK', headers, d)
942942
assert r.version is HTTPVersion.http11
943943

944+
def test_response_body_length(self):
945+
methods = [b'HEAD', b'GET']
946+
headers = {b'content-length': [b'15']}
947+
d = DummySocket()
948+
for method in methods:
949+
d.queue = []
950+
r = HTTP11Response(200, 'OK', headers, d, request_method=method)
951+
if method == b'HEAD':
952+
assert r._length == 0
953+
else:
954+
assert r._length == int(r.headers[b'content-length'][0])
955+
944956

945957
class DummySocket(object):
946958
def __init__(self):

0 commit comments

Comments
 (0)