Do not lowercase hostnames with custom-protocol(#1267)
Unix sockets are are case sensitive the same as other files
on standard unix file systems.
@@ -40,9 +40,10 @@ from .util.request import set_file_position
from .util.response import assert_header_parsing
from .util.retry import Retry
from .util.timeout import Timeout
-from .util.url import get_host, Url
+from .util.url import get_host, Url, NORMALIZABLE_SCHEMES
from .util.queue import LifoQueue
+
xrange = six.moves.xrange
log = logging.getLogger(__name__)
@@ -64,7 +65,7 @@ class ConnectionPool(object):
if not host:
raise LocationValueError("No host specified.")
- self.host = _ipv6_host(host).lower()
+ self.host = _ipv6_host(host, self.scheme)
self._proxy_host = host.lower()
self.port = port
@@ -432,7 +433,7 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
# TODO: Add optional support for socket.gethostbyname checking.
scheme, host, port = get_host(url)
- host = _ipv6_host(host).lower()
+ host = _ipv6_host(host, self.scheme)
# Use explicit default port for comparison when none is given
if self.port and not port:
@@ -884,7 +885,7 @@ def connection_from_url(url, **kw):
return HTTPConnectionPool(host, port=port, **kw)
-def _ipv6_host(host):
+def _ipv6_host(host, scheme):
"""
Process IPv6 address literals
"""
@@ -900,4 +901,6 @@ def _ipv6_host(host):
# percent sign might be URIencoded, convert it back into ASCII
if host.startswith('[') and host.endswith(']'):
host = host.replace('%25', '%').strip('[]')
+ if scheme in NORMALIZABLE_SCHEMES:
+ host = host.lower()
return host
