aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--netlib/http.py5
-rw-r--r--test/test_http.py1
2 files changed, 5 insertions, 1 deletions
diff --git a/netlib/http.py b/netlib/http.py
index 3f730a1a..076baf87 100644
--- a/netlib/http.py
+++ b/netlib/http.py
@@ -189,7 +189,10 @@ def parse_init_connect(line):
host, port = url.split(":")
except ValueError:
return None
- port = int(port)
+ try:
+ port = int(port)
+ except ValueError:
+ return None
return host, port, httpversion
diff --git a/test/test_http.py b/test/test_http.py
index a6161fbc..ed16fb4a 100644
--- a/test/test_http.py
+++ b/test/test_http.py
@@ -139,6 +139,7 @@ def test_parse_init_connect():
assert not http.parse_init_connect("GET host.com:443 HTTP/1.0")
assert not http.parse_init_connect("CONNECT host.com443 HTTP/1.0")
assert not http.parse_init_connect("CONNECT host.com:443 foo/1.0")
+ assert not http.parse_init_connect("CONNECT host.com:foo HTTP/1.0")
def test_prase_init_proxy():