Merge pull request #2311 from mhils/issue-2310

fix #2310
This commit is contained in:
Maximilian Hils
2017-05-03 18:41:07 +02:00
committed by GitHub
3 changed files with 12 additions and 3 deletions

View File

@@ -226,8 +226,9 @@ class Message(serializable.Serializable):
Raises:
ValueError, when the content-encoding is invalid and strict is True.
"""
self.raw_content = self.get_content(strict)
decoded = self.get_content(strict)
self.headers.pop("content-encoding", None)
self.content = decoded
def encode(self, e):
"""

View File

@@ -45,11 +45,11 @@ def tcp_flow():
class TestExportCurlCommand:
def test_get(self, get_request):
result = """curl -H 'header:qvalue' -H 'content-length:7' 'http://address:22/path?a=foo&a=bar&b=baz'"""
result = """curl -H 'header:qvalue' -H 'content-length:0' 'http://address:22/path?a=foo&a=bar&b=baz'"""
assert export.curl_command(get_request) == result
def test_post(self, post_request):
result = "curl -X POST 'http://address:22/path' --data-binary '{}'".format(
result = "curl -H 'content-length:256' -X POST 'http://address:22/path' --data-binary '{}'".format(
str(bytes(range(256)))[2:-1]
)
assert export.curl_command(post_request) == result

View File

@@ -117,6 +117,14 @@ class TestMessageContentEncoding:
assert r.content == b"message"
assert r.raw_content != b"message"
def test_update_content_length_header(self):
r = tutils.tresp()
assert int(r.headers["content-length"]) == 7
r.encode("gzip")
assert int(r.headers["content-length"]) == 27
r.decode()
assert int(r.headers["content-length"]) == 7
def test_modify(self):
r = tutils.tresp()
assert "content-encoding" not in r.headers