Update to v1.24.1

This addresses rhbz #1649155
This commit is contained in:
Jeremy Cline 2018-06-05 14:30:24 -04:00
commit 16f86578b1
No known key found for this signature in database
GPG key ID: 9223308FA9B246DB
5 changed files with 35 additions and 172 deletions

3
.gitignore vendored
View file

@ -19,3 +19,6 @@
/urllib3-1.20.tar.gz
/urllib3-1.21.1.tar.gz
/urllib3-1.22.tar.gz
/urllib3-1.23.tar.gz
/urllib3-1.24.tar.gz
/urllib3-1.24.1.tar.gz

View file

@ -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

View file

@ -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):

View file

@ -1,19 +1,15 @@
%global srcname urllib3
Name: python-%{srcname}
Version: 1.22
Release: 6%{?dist}
Version: 1.24.1
Release: 2%{?dist}
Summary: Python HTTP library with thread-safe connection pooling and file post
License: MIT
URL: https://github.com/shazow/urllib3
URL: https://github.com/urllib3/urllib3
Source0: %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz
# Used with Python 3.5+
# Unbundle ssl_match_hostname since we depend on it
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
Patch0001: 0001-Do-not-lowercase-hostnames-with-custom-protocol.patch
BuildArch: noarch
%description
@ -37,6 +33,7 @@ Requires: python-pysocks
BuildRequires: python2-devel
# For unittests
BuildRequires: python-backports-ssl_match_hostname
BuildRequires: python-nose
BuildRequires: python-nose-exclude
BuildRequires: python-coverage
@ -76,9 +73,7 @@ Python3 HTTP module with connection pooling and file POST abilities.
%prep
%setup -q -n %{srcname}-%{version}
%patch0 -p1 -b .recent-date
%patch1 -p1
%autosetup -p1 -n %{srcname}-%{version}
# Drop the dummyserver tests in koji. They fail there in real builds, but not
# in scratch builds (weird).
rm -rf test/with_dummyserver/
@ -88,6 +83,10 @@ rm -rf test/appengine/
# to do with Fedora in particular. They don't fail in upstream build infrastructure
rm -rf test/contrib/
# Tests for Python built without SSL, but Fedora builds with SSL. These tests
# fail when combined with the unbundling of backports-ssl_match_hostname
rm -f test/test_no_ssl.py
%build
%py2_build
%py3_build
@ -102,11 +101,11 @@ rm -rf %{buildroot}/%{python2_sitelib}/urllib3/packages/six.py*
rm -rf %{buildroot}/%{python2_sitelib}/urllib3/packages/ssl_match_hostname/
mkdir -p %{buildroot}/%{python2_sitelib}/urllib3/packages/
ln -s ../../six.py %{buildroot}/%{python2_sitelib}/urllib3/packages/six.py
ln -s ../../six.pyc %{buildroot}/%{python2_sitelib}/urllib3/packages/six.pyc
ln -s ../../six.pyo %{buildroot}/%{python2_sitelib}/urllib3/packages/six.pyo
ln -s ../../backports/ssl_match_hostname %{buildroot}/%{python2_sitelib}/urllib3/packages/ssl_match_hostname
ln -s %{python2_sitelib}/six.py %{buildroot}/%{python2_sitelib}/urllib3/packages/six.py
ln -s %{python2_sitelib}/six.pyc %{buildroot}/%{python2_sitelib}/urllib3/packages/six.pyc
ln -s %{python2_sitelib}/six.pyo %{buildroot}/%{python2_sitelib}/urllib3/packages/six.pyo
ln -s %{python2_sitelib}/backports/ssl_match_hostname \
%{buildroot}/%{python2_sitelib}/urllib3/packages/ssl_match_hostname
# Unbundle the Python 3 build
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py*
@ -114,18 +113,19 @@ rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/six*
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/ssl_match_hostname/
mkdir -p %{buildroot}/%{python3_sitelib}/urllib3/packages/
ln -s ../../six.py %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py
ln -s ../../../__pycache__/six.cpython-%{python3_version_nodots}.opt-1.pyc %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/
ln -s ../../../__pycache__/six.cpython-%{python3_version_nodots}.pyc %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/
# urllib3 requires Python 3.5 to use the standard library's match_hostname,
# which we ship in Fedora 26, so we can safely replace the bundled version with
# this stub which imports the necessary objects.
cp %{SOURCE1} %{buildroot}/%{python3_sitelib}/urllib3/packages/ssl_match_hostname.py
cp -a %{SOURCE1} %{buildroot}/%{python3_sitelib}/urllib3/packages/ssl_match_hostname.py
ln -s %{python3_sitelib}/six.py %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py
ln -s %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.opt-1.pyc \
%{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/
ln -s %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.pyc \
%{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/
%check
py.test
py.test-3
pushd test
PYTHONPATH=%{buildroot}%{python2_sitelib}:%{python2_sitelib} %{__python2} -m pytest -v
PYTHONPATH=%{buildroot}%{python3_sitelib}:%{python3_sitelib} %{__python3} -m pytest -v
popd
%files -n python2-%{srcname}
@ -143,6 +143,12 @@ py.test-3
%changelog
* Tue Nov 13 2018 Jeremy Cline <jeremy@jcline.org> - 1.24.1-2
- Adjust unbundling of ssl_match_hostname
* Mon Oct 29 2018 Jeremy Cline <jeremy@jcline.org> - 1.24.1-1
- Update to v1.24.1
* Thu May 03 2018 Lukas Slebodnik <lslebodn@fedoraproject.org> - 1.22-6
- Do not lowercase hostnames with custom-protocol (rhbz 1567862)
- upstream: https://github.com/urllib3/urllib3/issues/1267

View file

@ -1 +1 @@
SHA512 (urllib3-1.22.tar.gz) = 1b45a4a64e71847a4fc62b9263235d5b05b62076698fa324454efeb7ad065abd702cc9eadb2d396d9270b07e91e9bad94c52a4b9b115aadccb27f81955e6feab
SHA512 (urllib3-1.24.1.tar.gz) = 2f5453cf0ec1b65de9a9fca0fdb45664f7481507c875b7115c063cb177628b4b611377e588508ab8433e0797fc78b60fd3ea5cc5ac0a3f105d36bfff9a56f1f4