aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2016-01-30 22:03:24 +0100
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2016-01-30 22:03:24 +0100
commitd253ebc142d80708a1bdc065d3db05d1394e3819 (patch)
tree52769256609295723ce5cdd38031008b2891efbb
parent283c74a0eab01b817ba8c7d9f0341f9084ceae66 (diff)
downloadmitmproxy-d253ebc142d80708a1bdc065d3db05d1394e3819.tar.gz
mitmproxy-d253ebc142d80708a1bdc065d3db05d1394e3819.tar.bz2
mitmproxy-d253ebc142d80708a1bdc065d3db05d1394e3819.zip
fix test request and response headers
-rw-r--r--netlib/http/message.py2
-rw-r--r--netlib/tutils.py4
-rw-r--r--test/http/http1/test_assemble.py5
-rw-r--r--test/http/http1/test_read.py4
4 files changed, 8 insertions, 7 deletions
diff --git a/netlib/http/message.py b/netlib/http/message.py
index e4e799ca..28f55fa2 100644
--- a/netlib/http/message.py
+++ b/netlib/http/message.py
@@ -193,4 +193,4 @@ class decoded(object):
def __exit__(self, type, value, tb):
if self.ce:
- self.message.encode(self.ce) \ No newline at end of file
+ self.message.encode(self.ce)
diff --git a/netlib/tutils.py b/netlib/tutils.py
index e16f1a76..14b4ef06 100644
--- a/netlib/tutils.py
+++ b/netlib/tutils.py
@@ -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(),
diff --git a/test/http/http1/test_assemble.py b/test/http/http1/test_assemble.py
index ed94292d..31a62438 100644
--- a/test/http/http1/test_assemble.py
+++ b/test/http/http1/test_assemble.py
@@ -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():
diff --git a/test/http/http1/test_read.py b/test/http/http1/test_read.py
index 8a315508..90234070 100644
--- a/test/http/http1/test_read.py
+++ b/test/http/http1/test_read.py
@@ -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