From 0b532789a0823fcce68631ee78193ad2dd159572 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 21 Sep 2016 20:34:01 -0700 Subject: fix Response.make content-length header --- netlib/http/response.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'netlib') 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 -- cgit v1.2.3