diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2014-11-11 14:00:56 +1300 |
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2014-11-11 14:00:56 +1300 |
| commit | 5873516d991e5d04b565b93f95137e1cb2158aca (patch) | |
| tree | db911714493db7495909dcbeedf3c49f9b677970 /libmproxy/protocol/http.py | |
| parent | ec17e70d9e82bc6ae62300397b2f849c2d8dcc85 (diff) | |
| parent | 6f3b4eee3c3e30b391be457e38fb5ac67f8ef682 (diff) | |
| download | mitmproxy-5873516d991e5d04b565b93f95137e1cb2158aca.tar.gz mitmproxy-5873516d991e5d04b565b93f95137e1cb2158aca.tar.bz2 mitmproxy-5873516d991e5d04b565b93f95137e1cb2158aca.zip | |
Merge branch 'master' of ssh.github.com:mitmproxy/mitmproxy
Diffstat (limited to 'libmproxy/protocol/http.py')
| -rw-r--r-- | libmproxy/protocol/http.py | 12 |
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) |
