From 42656e693897ebc3adf53616c2633f464d824349 Mon Sep 17 00:00:00 2001 From: Andrew Grigorev Date: Mon, 30 Jan 2012 08:12:24 +0400 Subject: [PATCH] fixed usage of bad hostname (ipv6 addresses support is broken in urlparse until 2.7) --- tornado/simple_httpclient.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index 376d410c5..09293efaf 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -162,6 +162,7 @@ class _HTTPConnection(object): host = host[1:-1] if self.client.hostname_mapping is not None: host = self.client.hostname_mapping.get(host, host) + parsed._hostname = host # save correct hostname for _on_connect if request.allow_ipv6: af = socket.AF_UNSPEC @@ -241,7 +242,9 @@ class _HTTPConnection(object): if (self.request.validate_cert and isinstance(self.stream, SSLIOStream)): match_hostname(self.stream.socket.getpeercert(), - parsed.hostname) + # ipv6 addresses are broken until 2.7, here is + # correctly parsed value calculated in __init__ + parsed._hostname) if (self.request.method not in self._SUPPORTED_METHODS and not self.request.allow_nonstandard_methods): raise KeyError("unknown method %s" % self.request.method) -- 2.47.2