Latest upstream.

This commit is contained in:
Ralph Bean 2013-08-22 14:50:14 -04:00
parent da55d728d9
commit 1563f31238
8 changed files with 242 additions and 279 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/urllib3-1.5.tar.gz
/urllib3-1.7.tar.gz

View File

@ -1,28 +0,0 @@
From ea36acfc8a997a19ba1ead58de0d1f01e9eb540f Mon Sep 17 00:00:00 2001
From: kevin <kevinbjiang@gmail.com>
Date: Thu, 30 Aug 2012 00:14:12 -0400
Subject: [PATCH 1/4] Fix overwritten Accept header when proxy is used
When a request specifies both an Accept header and a proxy server, the
Accept header value is overwritten.
---
urllib3/poolmanager.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/urllib3/poolmanager.py b/urllib3/poolmanager.py
index 8f5b54c..7d7d6e4 100644
--- a/urllib3/poolmanager.py
+++ b/urllib3/poolmanager.py
@@ -141,7 +141,8 @@ def _set_proxy_headers(self, headers=None):
headers = headers or {}
# Same headers are curl passes for --proxy1.0
- headers['Accept'] = '*/*'
+ if 'Accept' not in headers:
+ headers['Accept'] = '*/*'
headers['Proxy-Connection'] = 'Keep-Alive'
return headers
--
1.7.10

View File

@ -1,20 +1,30 @@
Author: Jamie Strandboge <jamie@canonical.com>
Description: require SSL certificate validation by default by using
From 2d80688fab4ae0af2d4bd20568c328bd2aae128c Mon Sep 17 00:00:00 2001
From: Ralph Bean <rbean@redhat.com>
Date: Thu, 22 Aug 2013 14:18:45 -0400
Subject: [PATCH] Require SSL certificate validation by default by using
CERT_REQUIRED and using the system /etc/ssl/certs/ca-certificates.crt
Bug-Ubuntu: https://launchpad.net/bugs/1047054
Modified for Fedora by Ralph Bean <rbean@redhat.com>
Bug-Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=855320
Index: urllib3-1.5/urllib3/connectionpool.py
===================================================================
--- urllib3-1.5.orig/urllib3/connectionpool.py
+++ urllib3-1.5/urllib3/connectionpool.py
@@ -504,7 +504,7 @@ class HTTPSConnectionPool(HTTPConnection
Bug-Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=855320
Bug-Ubuntu: https://launchpad.net/bugs/1047054
---
urllib3/connectionpool.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/urllib3/connectionpool.py b/urllib3/connectionpool.py
index 621e1a8..7f4c322 100644
--- a/urllib3/connectionpool.py
+++ b/urllib3/connectionpool.py
@@ -556,8 +556,8 @@ class HTTPSConnectionPool(HTTPConnectionPool):
strict=False, timeout=None, maxsize=1,
block=False, headers=None,
key_file=None, cert_file=None,
- cert_reqs='CERT_NONE', ca_certs=None):
+ cert_reqs='CERT_REQUIRED', ca_certs='/etc/ssl/certs/ca-certificates.crt'):
_proxy=None, _proxy_headers=None,
- key_file=None, cert_file=None, cert_reqs=None,
- ca_certs=None, ssl_version=None,
+ key_file=None, cert_file=None, cert_reqs=ssl.CERT_REQUIRED,
+ ca_certs='/etc/ssl/certs/ca-certificates.crt', ssl_version=None,
assert_hostname=None, assert_fingerprint=None):
HTTPConnectionPool.__init__(self, host, port,
--
1.8.3.1
super(HTTPSConnectionPool, self).__init__(host, port,
strict, timeout, maxsize,

View File

@ -1,10 +1,25 @@
Index: urllib3-1.5/setup.cfg
===================================================================
--- urllib3-1.5.orig/setup.cfg
+++ urllib3-1.5/setup.cfg
@@ -1,5 +1,4 @@
From e5a73988f6790fb6961801f0db5992d8bd353e67 Mon Sep 17 00:00:00 2001
From: Ralph Bean <rbean@redhat.com>
Date: Thu, 22 Aug 2013 14:42:58 -0400
Subject: [PATCH] old nose compat
---
setup.cfg | 2 --
1 file changed, 2 deletions(-)
diff --git a/setup.cfg b/setup.cfg
index 8f6983c..a8b1d1d 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,8 +1,6 @@
[nosetests]
-logging-clear-handlers = true
with-coverage = true
cover-package = urllib3
-cover-min-percentage = 100
[egg_info]
tag_build =
--
1.8.3.1

View File

@ -1,89 +0,0 @@
Index: urllib3-1.5/test/test_collections.py
===================================================================
--- urllib3-1.5.orig/test/test_collections.py
+++ urllib3-1.5/test/test_collections.py
@@ -122,9 +122,11 @@ class TestLRUContainer(unittest.TestCase
def test_iter(self):
d = Container()
- with self.assertRaises(NotImplementedError):
+ def to_test():
for i in d:
self.fail("Iteration shouldn't be implemented.")
+ self.assertRaises(NotImplementedError, to_test)
+
if __name__ == '__main__':
unittest.main()
Index: urllib3-1.5/test/test_connectionpool.py
===================================================================
--- urllib3-1.5.orig/test/test_connectionpool.py
+++ urllib3-1.5/test/test_connectionpool.py
@@ -98,8 +98,7 @@ class TestConnectionPool(unittest.TestCa
def _test(exception, expect):
pool._make_request = lambda *args, **kwargs: _raise(exception)
- with self.assertRaises(expect):
- pool.request('GET', '/')
+ self.assertRaises(expect, pool.request, 'GET', '/')
self.assertEqual(pool.pool.qsize(), POOL_SIZE)
@@ -114,15 +113,13 @@ class TestConnectionPool(unittest.TestCa
# MaxRetryError, not EmptyPoolError
# See: https://github.com/shazow/urllib3/issues/76
pool._make_request = lambda *args, **kwargs: _raise(HTTPException)
- with self.assertRaises(MaxRetryError):
- pool.request('GET', '/', retries=1, pool_timeout=0.01)
+ self.assertRaises(MaxRetryError, pool.request, 'GET', '/', retries=1, pool_timeout=0.01)
self.assertEqual(pool.pool.qsize(), POOL_SIZE)
def test_assert_same_host(self):
c = connection_from_url('http://google.com:80')
- with self.assertRaises(HostChangedError):
- c.request('GET', 'http://yahoo.com:80', assert_same_host=True)
+ self.assertRaises(HostChangedError, c.request, 'GET', 'http://yahoo.com:80', assert_same_host=True)
def test_pool_close(self):
pool = connection_from_url('http://google.com:80')
@@ -139,16 +136,13 @@ class TestConnectionPool(unittest.TestCa
pool.close()
self.assertEqual(pool.pool, None)
- with self.assertRaises(ClosedPoolError):
- pool._get_conn()
+ self.assertRaises(ClosedPoolError, pool._get_conn)
pool._put_conn(conn3)
- with self.assertRaises(ClosedPoolError):
- pool._get_conn()
+ self.assertRaises(ClosedPoolError, pool._get_conn)
- with self.assertRaises(Empty):
- old_pool_queue.get(block=False)
+ self.assertRaises(Empty, old_pool_queue.get, block=False)
if __name__ == '__main__':
Index: urllib3-1.5/test/test_poolmanager.py
===================================================================
--- urllib3-1.5.orig/test/test_poolmanager.py
+++ urllib3-1.5/test/test_poolmanager.py
@@ -54,13 +54,11 @@ class TestPoolManager(unittest.TestCase)
p.clear()
self.assertEqual(len(p.pools), 0)
- with self.assertRaises(ClosedPoolError):
- conn_pool._get_conn()
+ self.assertRaises(ClosedPoolError, conn_pool._get_conn)
conn_pool._put_conn(conn)
- with self.assertRaises(ClosedPoolError):
- conn_pool._get_conn()
+ self.assertRaises(ClosedPoolError, conn_pool._get_conn)
self.assertEqual(len(p.pools), 0)

View File

@ -1,25 +1,152 @@
Index: urllib3-1.5/urllib3/_collections.py
===================================================================
--- urllib3-1.5.orig/urllib3/_collections.py
+++ urllib3-1.5/urllib3/_collections.py
@@ -10,7 +10,10 @@ from threading import Lock
From 67a50e427b3feef042ce9817b0ad0a05f01fefb7 Mon Sep 17 00:00:00 2001
From: Ralph Bean <rbean@redhat.com>
Date: Thu, 22 Aug 2013 14:37:02 -0400
Subject: [PATCH] unbundle
---
setup.py | 1 -
test-requirements.txt | 2 ++
test/test_collections.py | 2 +-
test/test_connectionpool.py | 9 ++++++++-
test/test_fields.py | 2 +-
test/test_filepost.py | 3 ++-
urllib3.egg-info/PKG-INFO | 2 +-
urllib3.egg-info/SOURCES.txt | 6 +-----
urllib3/_collections.py | 2 +-
urllib3/connectionpool.py | 10 ++++++++--
urllib3/fields.py | 2 +-
urllib3/filepost.py | 4 ++--
urllib3/response.py | 2 +-
urllib3/util.py | 2 +-
14 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/setup.py b/setup.py
index 392b885..82af89c 100644
--- a/setup.py
+++ b/setup.py
@@ -45,7 +45,6 @@ setup(name='urllib3',
url='http://urllib3.readthedocs.org/',
license='MIT',
packages=['urllib3', 'dummyserver',
- 'urllib3.packages', 'urllib3.packages.ssl_match_hostname',
'urllib3.contrib',
],
requires=requirements,
diff --git a/test-requirements.txt b/test-requirements.txt
index 1c90c10..e9a71d9 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,3 +1,5 @@
nose==1.3
tornado==2.4.1
coverage==3.6
+six
+backports.ssl_match_hostname
diff --git a/test/test_collections.py b/test/test_collections.py
index b44c58a..a8f2e55 100644
--- a/test/test_collections.py
+++ b/test/test_collections.py
@@ -1,7 +1,7 @@
import unittest
from urllib3._collections import RecentlyUsedContainer as Container
-from urllib3.packages import six
+import six
xrange = six.moves.xrange
diff --git a/test/test_connectionpool.py b/test/test_connectionpool.py
index a7e104a..876b4ee 100644
--- a/test/test_connectionpool.py
+++ b/test/test_connectionpool.py
@@ -1,7 +1,14 @@
import unittest
from urllib3.connectionpool import connection_from_url, HTTPConnectionPool
-from urllib3.packages.ssl_match_hostname import CertificateError
+
+try:
+ # python3.2+
+ from ssl import CertificateError
+except ImportError:
+ # Older python where the backport from pypi is installed
+ from backports.ssl_match_hostname import CertificateError
+
from urllib3.exceptions import (
ClosedPoolError,
EmptyPoolError,
diff --git a/test/test_fields.py b/test/test_fields.py
index 888c2d5..73dcd91 100644
--- a/test/test_fields.py
+++ b/test/test_fields.py
@@ -1,7 +1,7 @@
import unittest
from urllib3.fields import guess_content_type, RequestField
-from urllib3.packages.six import b, u
+from six import b, u
class TestRequestField(unittest.TestCase):
diff --git a/test/test_filepost.py b/test/test_filepost.py
index ca33d61..7176a29 100644
--- a/test/test_filepost.py
+++ b/test/test_filepost.py
@@ -2,7 +2,8 @@ import unittest
from urllib3.filepost import encode_multipart_formdata, iter_fields
from urllib3.fields import RequestField
-from urllib3.packages.six import b, u
+
+from six import b, u
BOUNDARY = '!! test boundary !!'
diff --git a/urllib3.egg-info/PKG-INFO b/urllib3.egg-info/PKG-INFO
index 13a467c..8232870 100644
--- a/urllib3.egg-info/PKG-INFO
+++ b/urllib3.egg-info/PKG-INFO
@@ -1,4 +1,4 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
Name: urllib3
Version: 1.7
Summary: HTTP library with thread-safe connection pooling, file post, and more.
diff --git a/urllib3.egg-info/SOURCES.txt b/urllib3.egg-info/SOURCES.txt
index 32759d9..9545027 100644
--- a/urllib3.egg-info/SOURCES.txt
+++ b/urllib3.egg-info/SOURCES.txt
@@ -38,8 +38,4 @@ urllib3.egg-info/dependency_links.txt
urllib3.egg-info/top_level.txt
urllib3/contrib/__init__.py
urllib3/contrib/ntlmpool.py
-urllib3/contrib/pyopenssl.py
-urllib3/packages/__init__.py
-urllib3/packages/ordered_dict.py
-urllib3/packages/six.py
-urllib3/packages/ssl_match_hostname/__init__.py
\ No newline at end of file
+urllib3/contrib/pyopenssl.py
\ No newline at end of file
diff --git a/urllib3/_collections.py b/urllib3/_collections.py
index 282b8d5..9210312 100644
--- a/urllib3/_collections.py
+++ b/urllib3/_collections.py
@@ -10,7 +10,7 @@ from threading import RLock
try: # Python 2.7+
from collections import OrderedDict
except ImportError:
- from .packages.ordered_dict import OrderedDict
+ try: # backport package
+ from ordereddict import OrderedDict
+ except ImportError:
+ from .packages.ordered_dict import OrderedDict
__all__ = ['RecentlyUsedContainer']
Index: urllib3-1.5/urllib3/connectionpool.py
===================================================================
--- urllib3-1.5.orig/urllib3/connectionpool.py
+++ urllib3-1.5/urllib3/connectionpool.py
@@ -51,8 +51,20 @@ from .exceptions import (
TimeoutError,
diff --git a/urllib3/connectionpool.py b/urllib3/connectionpool.py
index 7f4c322..21dec73 100644
--- a/urllib3/connectionpool.py
+++ b/urllib3/connectionpool.py
@@ -57,8 +57,14 @@ from .exceptions import (
ProxyError,
)
-from .packages.ssl_match_hostname import match_hostname, CertificateError
@ -28,135 +155,67 @@ Index: urllib3-1.5/urllib3/connectionpool.py
+ # python3.2+
+ from ssl import match_hostname, CertificateError
+except ImportError:
+ try:
+ # Older python where the backport from pypi is installed
+ from backports.ssl_match_hostname import match_hostname, CertificateError
+ except ImportError:
+ # Other older python we use our bundled copy
+ from .packages.ssl_match_hostname import match_hostname, CertificateError
+try:
+
+import six
+except ImportError:
+ from .packages import six
xrange = six.moves.xrange
Index: urllib3-1.5/urllib3/filepost.py
===================================================================
--- urllib3-1.5.orig/urllib3/filepost.py
+++ urllib3-1.5/urllib3/filepost.py
@@ -10,8 +10,12 @@ import mimetypes
diff --git a/urllib3/fields.py b/urllib3/fields.py
index ed01765..7a33b95 100644
--- a/urllib3/fields.py
+++ b/urllib3/fields.py
@@ -7,7 +7,7 @@
import email.utils
import mimetypes
-from .packages import six
+import six
def guess_content_type(filename, default='application/octet-stream'):
diff --git a/urllib3/filepost.py b/urllib3/filepost.py
index 4575582..bc4a161 100644
--- a/urllib3/filepost.py
+++ b/urllib3/filepost.py
@@ -10,8 +10,8 @@ import mimetypes
from uuid import uuid4
from io import BytesIO
-from .packages import six
-from .packages.six import b
+try:
+import six
+from six import b
+except ImportError:
+ from .packages import six
+ from .packages.six import b
from .fields import RequestField
writer = codecs.lookup('utf-8')[3]
Index: urllib3-1.5/urllib3/response.py
===================================================================
--- urllib3-1.5.orig/urllib3/response.py
+++ urllib3-1.5/urllib3/response.py
@@ -11,7 +11,10 @@ import zlib
from io import BytesIO
diff --git a/urllib3/response.py b/urllib3/response.py
index c7f93b8..a257cd7 100644
--- a/urllib3/response.py
+++ b/urllib3/response.py
@@ -10,7 +10,7 @@ import zlib
import io
from .exceptions import DecodeError
-from .packages.six import string_types as basestring
+try:
+ from six import string_types as basestring
+except ImportError:
+ from .packages.six import string_types as basestring
-from .packages.six import string_types as basestring, binary_type
+from six import string_types as basestring, binary_type
from .util import is_fp_closed
log = logging.getLogger(__name__)
Index: urllib3-1.5/urllib3/util.py
===================================================================
--- urllib3-1.5.orig/urllib3/util.py
+++ urllib3-1.5/urllib3/util.py
@@ -18,7 +18,10 @@ except ImportError: # `poll` doesn't exi
except ImportError: # `select` doesn't exist on AppEngine.
select = False
diff --git a/urllib3/util.py b/urllib3/util.py
index 39bceab..55faae5 100644
--- a/urllib3/util.py
+++ b/urllib3/util.py
@@ -31,7 +31,7 @@ try: # Test for SSL features
except ImportError:
pass
-from .packages import six
+try:
+import six
+except ImporError:
+ from .packages import six
from .exceptions import LocationParseError
from .exceptions import LocationParseError, SSLError
Index: urllib3-1.5/test/test_collections.py
===================================================================
--- urllib3-1.5.orig/test/test_collections.py
+++ urllib3-1.5/test/test_collections.py
@@ -1,7 +1,10 @@
import unittest
--
1.8.3.1
from urllib3._collections import RecentlyUsedContainer as Container
-from urllib3.packages import six
+try:
+ import six
+except ImportError:
+ from urllib3.packages import six
xrange = six.moves.xrange
Index: urllib3-1.5/test/test_connectionpool.py
===================================================================
--- urllib3-1.5.orig/test/test_connectionpool.py
+++ urllib3-1.5/test/test_connectionpool.py
@@ -1,7 +1,16 @@
import unittest
from urllib3.connectionpool import connection_from_url, HTTPConnectionPool
-from urllib3.packages.ssl_match_hostname import CertificateError
+try:
+ # python3.2+
+ from ssl import CertificateError
+except ImportError:
+ try:
+ # Older python where the backport from pypi is installed
+ from backports.ssl_match_hostname import CertificateError
+ except ImportError:
+ # Other older python we use our bundled copy
+ from urllib3.packages.ssl_match_hostname import CertificateError
from urllib3.exceptions import (
ClosedPoolError,
EmptyPoolError,
Index: urllib3-1.5/test/test_filepost.py
===================================================================
--- urllib3-1.5.orig/test/test_filepost.py
+++ urllib3-1.5/test/test_filepost.py
@@ -1,7 +1,10 @@
import unittest
from urllib3.filepost import encode_multipart_formdata, iter_fields
-from urllib3.packages.six import b, u
+try:
+ from six import b, u
+except ImportError:
+ from urllib3.packages.six import b, u
BOUNDARY = '!! test boundary !!'
Index: urllib3-1.5/setup.py
===================================================================
--- urllib3-1.5.orig/setup.py
+++ urllib3-1.5/setup.py
@@ -44,8 +44,7 @@ setup(name='urllib3',
author_email='andrey.petrov@shazow.net',
url='http://urllib3.readthedocs.org/',
license='MIT',
- packages=['urllib3', 'dummyserver', 'urllib3.packages',
- 'urllib3.packages.ssl_match_hostname',
+ packages=['urllib3', 'dummyserver', 'urllib3',
],
requires=requirements,
tests_require=tests_requirements,

View File

@ -7,8 +7,8 @@
%global srcname urllib3
Name: python-%{srcname}
Version: 1.5
Release: 7%{?dist}
Version: 1.7
Release: 1%{?dist}
Summary: Python HTTP library with thread-safe connection pooling and file post
License: MIT
@ -23,16 +23,8 @@ Patch0: python-urllib3-default-ssl-cert-validate.patch
# make all imports of things in packages try system copies first
Patch1: python-urllib3-unbundle.patch
# Fix accept header when behind a proxy
#https://github.com/shazow/urllib3/pull/93
#https://github.com/shazow/urllib3/pull/93.patch
Patch2: python-urllib3-accept-header-for-proxy.patch
# Remove logging-clear-handlers from setup.cfg because it's not available in RHEL6's nose
Patch100: python-urllib3-old-nose-compat.patch
### TODO: Send this upstream
# Compatibility with python-2.6's unittest
Patch101: python-urllib3-py2.6-compat.patch
BuildArch: noarch
@ -81,10 +73,8 @@ rm -rf urllib3/packages/
%patch0 -p1
%patch1 -p1
%patch2 -p1
%if 0%{?rhel} && 0%{?rhel} <= 6
%patch100 -p1
%patch101 -p1
%endif
%if 0%{?with_python3}
@ -139,6 +129,11 @@ popd
%endif # with_python3
%changelog
* Thu Aug 22 2013 Ralph Bean <rbean@redhat.com> - 1.7-1
- Update to latest upstream.
- Removed the accept-header proxy patch which is included in upstream now.
- Removed py2.6 compat patch which is included in upstream now.
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.5-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

View File

@ -1 +1 @@
3ee4b375a095bb6098f1ed75f8058e48 urllib3-1.5.tar.gz
a055b7f51b0c9ffadd7172c21b2885a3 urllib3-1.7.tar.gz