diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-09-17 02:39:42 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-09-17 02:39:42 +0200 |
commit | a07e43df8b3988f137b48957f978ad570d9dc782 (patch) | |
tree | 5bb1895014a0520e4f0263c95bee1db554e074fb /test | |
parent | dad9f06cb9403ac88d31d0ba8422034df2bc5078 (diff) | |
download | mitmproxy-a07e43df8b3988f137b48957f978ad570d9dc782.tar.gz mitmproxy-a07e43df8b3988f137b48957f978ad570d9dc782.tar.bz2 mitmproxy-a07e43df8b3988f137b48957f978ad570d9dc782.zip |
http1: add assemble_body function
Diffstat (limited to 'test')
-rw-r--r-- | test/http/http1/test_assemble.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/test/http/http1/test_assemble.py b/test/http/http1/test_assemble.py index 8a0a54f1..cdc8bda9 100644 --- a/test/http/http1/test_assemble.py +++ b/test/http/http1/test_assemble.py @@ -4,8 +4,8 @@ from netlib.http import CONTENT_MISSING, Headers from netlib.http.http1.assemble import ( assemble_request, assemble_request_head, assemble_response, assemble_response_head, _assemble_request_line, _assemble_request_headers, - _assemble_response_headers -) + _assemble_response_headers, + assemble_body) from netlib.tutils import treq, raises, tresp @@ -50,6 +50,17 @@ def test_assemble_response_head(): assert b"message" not in c +def test_assemble_body(): + c = list(assemble_body(Headers(), [b"body"])) + assert c == [b"body"] + + c = list(assemble_body(Headers(transfer_encoding="chunked"), [b"123456789a", b""])) + assert c == [b"a\r\n123456789a\r\n", b"0\r\n\r\n"] + + c = list(assemble_body(Headers(transfer_encoding="chunked"), [b"123456789a"])) + assert c == [b"a\r\n123456789a\r\n", b"0\r\n\r\n"] + + def test_assemble_request_line(): assert _assemble_request_line(treq()) == b"GET /path HTTP/1.1" @@ -83,8 +94,7 @@ def test_assemble_response_headers(): r = tresp(body=b"") r.headers["Transfer-Encoding"] = b"chunked" c = _assemble_response_headers(r) - assert b"Content-Length" in c - assert b"Transfer-Encoding" not in c + assert b"Transfer-Encoding" in c assert b"Proxy-Connection" not in _assemble_response_headers( tresp(headers=Headers(Proxy_Connection=b"42")) |