aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_protocol_http.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2016-01-24 23:15:42 +0100
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2016-02-04 09:52:03 +0100
commit4de9cbb61ee0bedd882518e72a1605ca999ccf97 (patch)
treed189a30cd211ee245952527bbad3e0a608ee3ced /test/test_protocol_http.py
parent2964a607ad927c01abb7596238f599ce7d546de8 (diff)
downloadmitmproxy-4de9cbb61ee0bedd882518e72a1605ca999ccf97.tar.gz
mitmproxy-4de9cbb61ee0bedd882518e72a1605ca999ccf97.tar.bz2
mitmproxy-4de9cbb61ee0bedd882518e72a1605ca999ccf97.zip
rename test file
Diffstat (limited to 'test/test_protocol_http.py')
-rw-r--r--test/test_protocol_http.py92
1 files changed, 0 insertions, 92 deletions
diff --git a/test/test_protocol_http.py b/test/test_protocol_http.py
deleted file mode 100644
index 489be3f9..00000000
--- a/test/test_protocol_http.py
+++ /dev/null
@@ -1,92 +0,0 @@
-from io import BytesIO
-from netlib.exceptions import HttpSyntaxException
-from netlib.http import http1
-from netlib.tcp import TCPClient
-from netlib.tutils import treq, raises
-from . import tutils, tservers
-
-
-class TestHTTPResponse:
-
- def test_read_from_stringio(self):
- s = (
- b"HTTP/1.1 200 OK\r\n"
- b"Content-Length: 7\r\n"
- b"\r\n"
- b"content\r\n"
- b"HTTP/1.1 204 OK\r\n"
- b"\r\n"
- )
- rfile = BytesIO(s)
- r = http1.read_response(rfile, treq())
- assert r.status_code == 200
- assert r.content == b"content"
- assert http1.read_response(rfile, treq()).status_code == 204
-
- rfile = BytesIO(s)
- # HEAD must not have content by spec. We should leave it on the pipe.
- r = http1.read_response(rfile, treq(method=b"HEAD"))
- assert r.status_code == 200
- assert r.content == b""
-
- with raises(HttpSyntaxException):
- http1.read_response(rfile, treq())
-
-
-class TestHTTPFlow(object):
-
- def test_repr(self):
- f = tutils.tflow(resp=True, err=True)
- assert repr(f)
-
-
-class TestInvalidRequests(tservers.HTTPProxTest):
- ssl = True
-
- def test_double_connect(self):
- p = self.pathoc()
- r = p.request("connect:'%s:%s'" % ("127.0.0.1", self.server2.port))
- assert r.status_code == 400
- assert "Invalid HTTP request form" in r.content
-
- def test_relative_request(self):
- p = self.pathoc_raw()
- p.connect()
- r = p.request("get:/p/200")
- assert r.status_code == 400
- assert "Invalid HTTP request form" in r.content
-
-
-class TestExpectHeader(tservers.HTTPProxTest):
-
- def test_simple(self):
- client = TCPClient(("127.0.0.1", self.proxy.port))
- client.connect()
-
- # call pathod server, wait a second to complete the request
- client.wfile.write(
- b"POST http://localhost:%d/p/200 HTTP/1.1\r\n"
- b"Expect: 100-continue\r\n"
- b"Content-Length: 16\r\n"
- b"\r\n" % self.server.port
- )
- client.wfile.flush()
-
- assert client.rfile.readline() == "HTTP/1.1 100 Continue\r\n"
- assert client.rfile.readline() == "\r\n"
-
- client.wfile.write(b"0123456789abcdef\r\n")
- client.wfile.flush()
-
- resp = http1.read_response(client.rfile, treq())
- assert resp.status_code == 200
-
- client.finish()
-
-
-class TestHeadContentLength(tservers.HTTPProxTest):
-
- def test_head_content_length(self):
- p = self.pathoc()
- resp = p.request("""head:'%s/p/200:h"Content-Length"="42"'""" % self.server.urlbase)
- assert resp.headers["Content-Length"] == "42"