Use the raw request version when the original is not accessible (#1352)

This commit is contained in:
Batuhan Taskaya 2022-04-14 17:41:12 +03:00 committed by GitHub
parent 9f1ec6d5cc
commit e6d0bfec7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,7 +71,11 @@ class HTTPResponse(HTTPMessage):
@property
def headers(self):
try:
raw_version = self._orig.raw._original_response.version
raw = self._orig.raw
if getattr(raw, '_original_response', None):
raw_version = raw._original_response.version
else:
raw_version = raw.version
except AttributeError:
# Assume HTTP/1.1
raw_version = 11
@ -79,7 +83,7 @@ class HTTPResponse(HTTPMessage):
9: '0.9',
10: '1.0',
11: '1.1',
20: '2',
20: '2.0',
}[raw_version]
original = self._orig