summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@fedoraproject.org>2018-04-12 00:34:07 +0200
committerLukas Slebodnik <lslebodn@fedoraproject.org>2018-04-26 19:03:50 +0200
commit92da9e010f506cdd2408f6915ff87926f907c927 (patch)
treee818cb06a809d31ec427024ce239a8636ae1380d
parentdb444ec77836ef1e6aa129bc3507f8e838f1ceb6 (diff)
downloadurllib3-92da9e010f506cdd2408f6915ff87926f907c927.tar.gz
Do not lowercase hostnames with custom-protocol(#1267)
Unix sockets are are case sensitive the same as other files on standard unix file systems.
-rw-r--r--urllib3/connectionpool.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/urllib3/connectionpool.py b/urllib3/connectionpool.py
index 0b38963a..8fcb0bce 100644
--- a/urllib3/connectionpool.py
+++ b/urllib3/connectionpool.py
@@ -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