urllib3 v1.23 (rhbz 1586072)
This commit is contained in:
parent
0905637ec9
commit
0b513a8d72
@ -1,114 +0,0 @@
|
||||
From 92da9e010f506cdd2408f6915ff87926f907c927 Mon Sep 17 00:00:00 2001
|
||||
From: Lukas Slebodnik <lslebodn@fedoraproject.org>
|
||||
Date: Thu, 12 Apr 2018 00:34:07 +0200
|
||||
Subject: [PATCH 1] Do not lowercase hostnames with custom-protocol(#1267)
|
||||
|
||||
Unix sockets are are case sensitive the same as other files
|
||||
on standard unix file systems.
|
||||
---
|
||||
urllib3/connectionpool.py | 11 +++++++----
|
||||
1 file changed, 7 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/test/test_connectionpool.py b/test/test_connectionpool.py
|
||||
index d8b8a83..4b74ab4 100644
|
||||
--- a/test/test_connectionpool.py
|
||||
+++ b/test/test_connectionpool.py
|
||||
@@ -32,6 +32,19 @@ from ssl import SSLError as BaseSSLError
|
||||
from dummyserver.server import DEFAULT_CA
|
||||
|
||||
|
||||
+class HTTPUnixConnection(HTTPConnection):
|
||||
+ def __init__(self, host, timeout=60, **kwargs):
|
||||
+ super(HTTPUnixConnection, self).__init__('localhost')
|
||||
+ self.unix_socket = host
|
||||
+ self.timeout = timeout
|
||||
+ self.sock = None
|
||||
+
|
||||
+
|
||||
+class HTTPUnixConnectionPool(HTTPConnectionPool):
|
||||
+ scheme = 'http+unix'
|
||||
+ ConnectionCls = HTTPUnixConnection
|
||||
+
|
||||
+
|
||||
class TestConnectionPool(object):
|
||||
"""
|
||||
Tests in this suite should exercise the ConnectionPool functionality
|
||||
@@ -138,6 +151,31 @@ class TestConnectionPool(object):
|
||||
with HTTPSConnectionPool(b) as c:
|
||||
assert not c.is_same_host(a)
|
||||
|
||||
+ @pytest.mark.parametrize('a, b', [
|
||||
+ ('%2Fvar%2Frun%2Fdocker.sock',
|
||||
+ 'http+unix://%2Fvar%2Frun%2Fdocker.sock'),
|
||||
+ ('%2Fvar%2Frun%2Fdocker.sock',
|
||||
+ 'http+unix://%2Fvar%2Frun%2Fdocker.sock/'),
|
||||
+ ('%2Fvar%2Frun%2Fdocker.sock',
|
||||
+ 'http+unix://%2Fvar%2Frun%2Fdocker.sock/abracadabra'),
|
||||
+ ('%2Ftmp%2FTEST.sock', 'http+unix://%2Ftmp%2FTEST.sock'),
|
||||
+ ('%2Ftmp%2FTEST.sock', 'http+unix://%2Ftmp%2FTEST.sock/'),
|
||||
+ ('%2Ftmp%2FTEST.sock', 'http+unix://%2Ftmp%2FTEST.sock/abracadabra'),
|
||||
+ ])
|
||||
+ def test_same_host_custom_protocol(self, a, b):
|
||||
+ with HTTPUnixConnectionPool(a) as c:
|
||||
+ assert c.is_same_host(b)
|
||||
+
|
||||
+ @pytest.mark.parametrize('a, b', [
|
||||
+ ('%2Ftmp%2Ftest.sock', 'http+unix://%2Ftmp%2FTEST.sock'),
|
||||
+ ('%2Ftmp%2Ftest.sock', 'http+unix://%2Ftmp%2FTEST.sock/'),
|
||||
+ ('%2Ftmp%2Ftest.sock', 'http+unix://%2Ftmp%2FTEST.sock/abracadabra'),
|
||||
+ ('%2Fvar%2Frun%2Fdocker.sock', 'http+unix://%2Ftmp%2FTEST.sock'),
|
||||
+ ])
|
||||
+ def test_not_same_host_custom_protocol(self, a, b):
|
||||
+ with HTTPUnixConnectionPool(a) as c:
|
||||
+ assert not c.is_same_host(b)
|
||||
+
|
||||
def test_max_connections(self):
|
||||
with HTTPConnectionPool(host='localhost', maxsize=1, block=True) as pool:
|
||||
pool._get_conn(timeout=0.01)
|
||||
diff --git a/urllib3/connectionpool.py b/urllib3/connectionpool.py
|
||||
index ec9600f..2d7a26b 100644
|
||||
--- a/urllib3/connectionpool.py
|
||||
+++ b/urllib3/connectionpool.py
|
||||
@@ -40,7 +40,7 @@ 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
|
||||
|
||||
|
||||
if six.PY2:
|
||||
@@ -68,7 +68,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
|
||||
|
||||
@@ -434,7 +434,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:
|
||||
@@ -886,7 +886,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
|
||||
"""
|
||||
@@ -902,4 +902,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
|
@ -1,26 +0,0 @@
|
||||
From edd7a0063d25f1a7f34306f9a9488247593888a9 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Wilcox <crwilcox@google.com>
|
||||
Date: Fri, 20 Apr 2018 15:50:40 -0700
|
||||
Subject: [PATCH] Address #1365. CertificateError str repr is tuple, not str.
|
||||
|
||||
Signed-off-by: Jeremy Cline <jcline@redhat.com>
|
||||
---
|
||||
test/test_connection.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/test/test_connection.py b/test/test_connection.py
|
||||
index be50f6c..dfc757d 100644
|
||||
--- a/test/test_connection.py
|
||||
+++ b/test/test_connection.py
|
||||
@@ -38,7 +38,7 @@ class TestConnection(object):
|
||||
with mock.patch('urllib3.connection.log.error') as mock_log:
|
||||
_match_hostname(cert, asserted_hostname)
|
||||
except CertificateError as e:
|
||||
- assert str(e) == "hostname 'bar' doesn't match 'foo'"
|
||||
+ assert "hostname 'bar' doesn't match 'foo'" in str(e)
|
||||
mock_log.assert_called_once_with(
|
||||
'Certificate did not match expected hostname: %s. '
|
||||
'Certificate: %s',
|
||||
--
|
||||
2.17.0
|
||||
|
@ -1,32 +0,0 @@
|
||||
From 4bff1e93d2dd4663d422d7e290473d9189cec5db Mon Sep 17 00:00:00 2001
|
||||
From: Dominique Leuenberger <dimstar@opensuse.org>
|
||||
Date: Sun, 31 Dec 2017 15:11:16 +0100
|
||||
Subject: [PATCH] Move RECENT_DATE to 2017-06-30
|
||||
|
||||
The test suite expects the current date to be no more than two years in the future
|
||||
of RECENT_DATE, which just serves as a reference point.
|
||||
|
||||
Also clarify the comment about how to update RECENT_DATE
|
||||
|
||||
Fixes #1303
|
||||
|
||||
diff --git a/urllib3/connection.py b/urllib3/connection.py
|
||||
index 06bcbde1a..a03b573f0 100644
|
||||
--- a/urllib3/connection.py
|
||||
+++ b/urllib3/connection.py
|
||||
@@ -56,10 +56,11 @@ class ConnectionError(Exception):
|
||||
'https': 443,
|
||||
}
|
||||
|
||||
-# When updating RECENT_DATE, move it to
|
||||
-# within two years of the current date, and no
|
||||
-# earlier than 6 months ago.
|
||||
-RECENT_DATE = datetime.date(2016, 1, 1)
|
||||
+# When updating RECENT_DATE, move it to within two years of the current date,
|
||||
+# and not less than 6 months ago.
|
||||
+# Example: if Today is 2018-01-01, then RECENT_DATE should be any date on or
|
||||
+# after 2016-01-01 (today - 2 years) AND before 2017-07-01 (today - 6 months)
|
||||
+RECENT_DATE = datetime.date(2017, 6, 30)
|
||||
|
||||
|
||||
class DummyConnection(object):
|
@ -4,8 +4,8 @@
|
||||
%bcond_without tests
|
||||
|
||||
Name: python-%{srcname}
|
||||
Version: 1.22
|
||||
Release: 10%{?dist}
|
||||
Version: 1.23
|
||||
Release: 1%{?dist}
|
||||
Summary: Python HTTP library with thread-safe connection pooling and file post
|
||||
|
||||
License: MIT
|
||||
@ -13,12 +13,6 @@ URL: https://github.com/shazow/urllib3
|
||||
Source0: %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz
|
||||
# Used with Python 3.5+
|
||||
Source1: ssl_match_hostname_py3.py
|
||||
# https://github.com/shazow/urllib3/commit/4bff1e93d2dd4663d422d7e290473d9189cec5db
|
||||
Patch0: python-urllib3-recent-date.patch
|
||||
# https://github.com/urllib3/urllib3/commit/9f09cb4b9d69bd8944c881f61b8fe933ad425b5b
|
||||
Patch1: 0001-Do-not-lowercase-hostnames-with-custom-protocol.patch
|
||||
# https://github.com/urllib3/urllib3/pull/1375 - Python 3.7 support
|
||||
Patch2: Address-1365.-CertificateError-str-repr-is-tuple-not.patch
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
@ -79,9 +73,6 @@ Python3 HTTP module with connection pooling and file POST abilities.
|
||||
|
||||
%prep
|
||||
%setup -q -n %{srcname}-%{version}
|
||||
%patch0 -p1 -b .recent-date
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
# Drop the dummyserver tests in koji. They fail there in real builds, but not
|
||||
# in scratch builds (weird).
|
||||
rm -rf test/with_dummyserver/
|
||||
@ -148,6 +139,9 @@ py.test-3
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Jun 05 2018 Jeremy Cline <jeremy@jcline.org> - 1.23-1
|
||||
- Update to the latest upstream release (rhbz 1586072)
|
||||
|
||||
* Wed May 30 2018 Jeremy Cline <jeremy@jcline.org> - 1.22-10
|
||||
- Backport patch to support Python 3.7 (rhbz 1584112)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user