From e6d0bfec7c0811f3260dfa8455c53d6dbcff76c7 Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Thu, 14 Apr 2022 17:41:12 +0300 Subject: [PATCH] Use the raw request version when the original is not accessible (#1352) --- httpie/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/httpie/models.py b/httpie/models.py index 5faf4ee0..d97b55e3 100644 --- a/httpie/models.py +++ b/httpie/models.py @@ -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