summaryrefslogtreecommitdiff
path: root/Lib/httplib.py
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2004-09-16 03:31:21 +0000
committerSkip Montanaro <skip@pobox.com>2004-09-16 03:31:21 +0000
commit01b69f7605b783be8f27b72256e623161286ff0a (patch)
tree526a10f38ec0033902e8cb0807b4a09ab910e4d7 /Lib/httplib.py
parentb4a4e1d3a737ce25e7089c13254a630dbef0426a (diff)
downloadcpython-git-01b69f7605b783be8f27b72256e623161286ff0a.tar.gz
backport ipv6 address fix
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r--Lib/httplib.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 40fad26c87..0b6a9d2db3 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -510,8 +510,9 @@ class HTTPConnection:
def _set_hostport(self, host, port):
if port is None:
- i = host.find(':')
- if i >= 0:
+ i = host.rfind(':')
+ j = host.rfind(']') # ipv6 addresses have [...]
+ if i > j:
try:
port = int(host[i+1:])
except ValueError:
@@ -519,6 +520,8 @@ class HTTPConnection:
host = host[:i]
else:
port = self.default_port
+ if host[0] == '[' and host[-1] == ']':
+ host = host[1:-1]
self.host = host
self.port = port