mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
fix test request and response headers
This commit is contained in:
parent
283c74a0ea
commit
d253ebc142
@ -193,4 +193,4 @@ class decoded(object):
|
||||
|
||||
def __exit__(self, type, value, tb):
|
||||
if self.ce:
|
||||
self.message.encode(self.ce)
|
||||
self.message.encode(self.ce)
|
||||
|
@ -105,7 +105,7 @@ def treq(**kwargs):
|
||||
port=22,
|
||||
path=b"/path",
|
||||
http_version=b"HTTP/1.1",
|
||||
headers=Headers(header="qvalue"),
|
||||
headers=Headers(header="qvalue", content_length="7"),
|
||||
content=b"content"
|
||||
)
|
||||
default.update(kwargs)
|
||||
@ -121,7 +121,7 @@ def tresp(**kwargs):
|
||||
http_version=b"HTTP/1.1",
|
||||
status_code=200,
|
||||
reason=b"OK",
|
||||
headers=Headers(header_response="svalue"),
|
||||
headers=Headers(header_response="svalue", content_length="7"),
|
||||
content=b"message",
|
||||
timestamp_start=time.time(),
|
||||
timestamp_end=time.time(),
|
||||
|
@ -24,10 +24,11 @@ def test_assemble_request():
|
||||
|
||||
|
||||
def test_assemble_request_head():
|
||||
c = assemble_request_head(treq())
|
||||
c = assemble_request_head(treq(content="foo"))
|
||||
assert b"GET" in c
|
||||
assert b"qvalue" in c
|
||||
assert b"content" not in c
|
||||
assert b"content-length" in c
|
||||
assert b"foo" not in c
|
||||
|
||||
|
||||
def test_assemble_response():
|
||||
|
@ -159,10 +159,10 @@ def test_expected_http_body_size():
|
||||
|
||||
# no length
|
||||
assert expected_http_body_size(
|
||||
treq()
|
||||
treq(headers=Headers())
|
||||
) == 0
|
||||
assert expected_http_body_size(
|
||||
treq(), tresp()
|
||||
treq(headers=Headers()), tresp(headers=Headers())
|
||||
) == -1
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user