aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-09-21 21:49:14 -0700
committerGitHub <noreply@github.com>2016-09-21 21:49:14 -0700
commit9e0b935fa241bc50b8c91cbdae32cb1df41ef3f1 (patch)
tree642e61bb76bd2819191f0a9f8c2d5faef352721a /netlib
parentd5427c7298b0c6aee009a86dec041011427689e9 (diff)
parent0b532789a0823fcce68631ee78193ad2dd159572 (diff)
downloadmitmproxy-9e0b935fa241bc50b8c91cbdae32cb1df41ef3f1.tar.gz
mitmproxy-9e0b935fa241bc50b8c91cbdae32cb1df41ef3f1.tar.bz2
mitmproxy-9e0b935fa241bc50b8c91cbdae32cb1df41ef3f1.zip
Merge pull request #1564 from mhils/issue-1554
Fix Response.make content-length header
Diffstat (limited to 'netlib')
-rw-r--r--netlib/http/response.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/netlib/http/response.py b/netlib/http/response.py
index ae29298f..385e233a 100644
--- a/netlib/http/response.py
+++ b/netlib/http/response.py
@@ -84,15 +84,6 @@ class Response(message.Message):
(),
None
)
- # Assign this manually to update the content-length header.
- if isinstance(content, bytes):
- resp.content = content
- elif isinstance(content, str):
- resp.text = content
- else:
- raise TypeError("Expected content to be str or bytes, but is {}.".format(
- type(content).__name__
- ))
# Headers can be list or dict, we differentiate here.
if isinstance(headers, dict):
@@ -104,6 +95,16 @@ class Response(message.Message):
type(headers).__name__
))
+ # Assign this manually to update the content-length header.
+ if isinstance(content, bytes):
+ resp.content = content
+ elif isinstance(content, str):
+ resp.text = content
+ else:
+ raise TypeError("Expected content to be str or bytes, but is {}.".format(
+ type(content).__name__
+ ))
+
return resp
@property