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

Commit 5579103

Browse files
committed
fix HEAD request body length
1 parent 55f7ec9 commit 5579103

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

hyper/http11/response.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ def __init__(self, code, reason, headers, sock, connection=None,
5353
self._expect_close = True
5454

5555
# The expected length of the body.
56-
try:
57-
self._length = int(self.headers[b'content-length'][0])
58-
except KeyError:
59-
self._length = None
56+
if request_method.upper() != b'HEAD':
57+
try:
58+
self._length = int(self.headers[b'content-length'][0])
59+
except KeyError:
60+
self._length = None
61+
else:
62+
self._length = 0
6063

6164
# Whether we expect a chunked response.
6265
self._chunked = (

0 commit comments

Comments
 (0)