aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-11-07 09:52:46 +0100
committerMaximilian Hils <git@maximilianhils.com>2014-11-07 09:52:46 +0100
commitc3ec5515466fe7ba970bc7cb2578dad4c845e5bc (patch)
tree3d3d3295ea6d009137113ccb655540b64ebd334d /libmproxy/protocol
parentdc142682cb930cb3903a2fc66d4785bd5367360b (diff)
downloadmitmproxy-c3ec5515466fe7ba970bc7cb2578dad4c845e5bc.tar.gz
mitmproxy-c3ec5515466fe7ba970bc7cb2578dad4c845e5bc.tar.bz2
mitmproxy-c3ec5515466fe7ba970bc7cb2578dad4c845e5bc.zip
fix #401
Diffstat (limited to 'libmproxy/protocol')
-rw-r--r--libmproxy/protocol/http.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index 1472f2ca..c8974d25 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -434,11 +434,9 @@ class HTTPRequest(HTTPMessage):
self.host,
self.port)]
- if self.content:
+ # If content is defined (i.e. not None or CONTENT_MISSING), we always add a content-length header.
+ if self.content or self.content == "":
headers["Content-Length"] = [str(len(self.content))]
- elif 'Transfer-Encoding' in self.headers:
- # content-length for e.g. chuncked transfer-encoding with no content
- headers["Content-Length"] = ["0"]
return str(headers)
@@ -761,11 +759,9 @@ class HTTPResponse(HTTPMessage):
if not preserve_transfer_encoding:
del headers['Transfer-Encoding']
- if self.content:
+ # If content is defined (i.e. not None or CONTENT_MISSING), we always add a content-length header.
+ if self.content or self.content == "":
headers["Content-Length"] = [str(len(self.content))]
- # add content-length for chuncked transfer-encoding with no content
- elif not preserve_transfer_encoding and 'Transfer-Encoding' in self.headers:
- headers["Content-Length"] = ["0"]
return str(headers)