diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-07-14 23:02:14 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-07-22 15:30:51 +0200 |
commit | f50deb7b763d093a22a4d331e16465a2fb0329cf (patch) | |
tree | a11e92fca2a0deffeb801cc6f931bd79aec0d669 /test/http/test_semantics.py | |
parent | bd5ee212840e3be731ea93e14ef1375745383d88 (diff) | |
download | mitmproxy-f50deb7b763d093a22a4d331e16465a2fb0329cf.tar.gz mitmproxy-f50deb7b763d093a22a4d331e16465a2fb0329cf.tar.bz2 mitmproxy-f50deb7b763d093a22a4d331e16465a2fb0329cf.zip |
move bits around
Diffstat (limited to 'test/http/test_semantics.py')
-rw-r--r-- | test/http/test_semantics.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/http/test_semantics.py b/test/http/test_semantics.py new file mode 100644 index 00000000..c4605302 --- /dev/null +++ b/test/http/test_semantics.py @@ -0,0 +1,54 @@ +import cStringIO +import textwrap +import binascii + +from netlib import http, odict, tcp +from netlib.http import http1 +from .. import tutils, tservers + +def test_httperror(): + e = http.exceptions.HttpError(404, "Not found") + assert str(e) + + +def test_parse_url(): + assert not http.parse_url("") + + u = "http://foo.com:8888/test" + s, h, po, pa = http.parse_url(u) + assert s == "http" + assert h == "foo.com" + assert po == 8888 + assert pa == "/test" + + s, h, po, pa = http.parse_url("http://foo/bar") + assert s == "http" + assert h == "foo" + assert po == 80 + assert pa == "/bar" + + s, h, po, pa = http.parse_url("http://user:pass@foo/bar") + assert s == "http" + assert h == "foo" + assert po == 80 + assert pa == "/bar" + + s, h, po, pa = http.parse_url("http://foo") + assert pa == "/" + + s, h, po, pa = http.parse_url("https://foo") + assert po == 443 + + assert not http.parse_url("https://foo:bar") + assert not http.parse_url("https://foo:") + + # Invalid IDNA + assert not http.parse_url("http://\xfafoo") + # Invalid PATH + assert not http.parse_url("http:/\xc6/localhost:56121") + # Null byte in host + assert not http.parse_url("http://foo\0") + # Port out of range + assert not http.parse_url("http://foo:999999") + # Invalid IPv6 URL - see http://www.ietf.org/rfc/rfc2732.txt + assert not http.parse_url('http://lo[calhost') |