mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-01-12 22:48:54 +08:00
fix #2310
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user