Fixes #10860: Handle empty port after port delimiter in httplib
Thanks, Shawn Ligocki!
3.x version will come as a separate patch.
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 9853285..19bcd1b 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -715,7 +715,10 @@
try:
port = int(host[i+1:])
except ValueError:
- raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
+ if host[i+1:] == "": # http://foo.com:/ == http://foo.com/
+ port = self.default_port
+ else:
+ raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
host = host[:i]
else:
port = self.default_port