summaryrefslogtreecommitdiff
path: root/devel
diff options
context:
space:
mode:
authorwiz <wiz@pkgsrc.org>2015-11-24 10:27:26 +0000
committerwiz <wiz@pkgsrc.org>2015-11-24 10:27:26 +0000
commitf4ef7b1061f08f83e6feeb5db4febf9d18de3c26 (patch)
treef65ed5e3e067e8fd58ad0f1bace98f567dc2903b /devel
parent557a74e77a43008f6b20896b1aa02d1b452180e7 (diff)
downloadpkgsrc-f4ef7b1061f08f83e6feeb5db4febf9d18de3c26.tar.gz
Pull upstream patch for compatibility to py-requests-2.8.0.
https://github.com/sigmavirus24/requests-toolbelt/commit/d4eba75097c0f65448afb6dfab2029d3fefb02b9 Bump PKGREVISION. Use MASTER_SITES_PYPI while here.
Diffstat (limited to 'devel')
-rw-r--r--devel/py-requests-toolbelt/Makefile5
-rw-r--r--devel/py-requests-toolbelt/PLIST5
-rw-r--r--devel/py-requests-toolbelt/distinfo5
-rw-r--r--devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth___digest__auth__compat.py47
-rw-r--r--devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth_guess.py108
-rw-r--r--devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth_http__proxy__digest.py68
6 files changed, 234 insertions, 4 deletions
diff --git a/devel/py-requests-toolbelt/Makefile b/devel/py-requests-toolbelt/Makefile
index 022e72bcefa..493429a89b7 100644
--- a/devel/py-requests-toolbelt/Makefile
+++ b/devel/py-requests-toolbelt/Makefile
@@ -1,9 +1,10 @@
-# $NetBSD: Makefile,v 1.3 2015/04/05 14:20:03 wiz Exp $
+# $NetBSD: Makefile,v 1.4 2015/11/24 10:27:26 wiz Exp $
DISTNAME= requests-toolbelt-0.4.0
PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
+PKGREVISION= 1
CATEGORIES= devel
-MASTER_SITES= https://pypi.python.org/packages/source/r/requests-toolbelt/
+MASTER_SITES= ${MASTER_SITE_PYPI:=r/requests-toolbelt/}
MAINTAINER= pkgsrc-users@NetBSD.org
HOMEPAGE= https://pypi.python.org/pypi/requests-toolbelt
diff --git a/devel/py-requests-toolbelt/PLIST b/devel/py-requests-toolbelt/PLIST
index c5a4e9c6283..aad35cb6d70 100644
--- a/devel/py-requests-toolbelt/PLIST
+++ b/devel/py-requests-toolbelt/PLIST
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.2 2015/04/05 14:20:03 wiz Exp $
+@comment $NetBSD: PLIST,v 1.3 2015/11/24 10:27:26 wiz Exp $
${PYSITELIB}/${EGG_INFODIR}/PKG-INFO
${PYSITELIB}/${EGG_INFODIR}/SOURCES.txt
${PYSITELIB}/${EGG_INFODIR}/dependency_links.txt
@@ -25,6 +25,9 @@ ${PYSITELIB}/requests_toolbelt/adapters/ssl.pyo
${PYSITELIB}/requests_toolbelt/auth/__init__.py
${PYSITELIB}/requests_toolbelt/auth/__init__.pyc
${PYSITELIB}/requests_toolbelt/auth/__init__.pyo
+${PYSITELIB}/requests_toolbelt/auth/_digest_auth_compat.py
+${PYSITELIB}/requests_toolbelt/auth/_digest_auth_compat.pyc
+${PYSITELIB}/requests_toolbelt/auth/_digest_auth_compat.pyo
${PYSITELIB}/requests_toolbelt/auth/guess.py
${PYSITELIB}/requests_toolbelt/auth/guess.pyc
${PYSITELIB}/requests_toolbelt/auth/guess.pyo
diff --git a/devel/py-requests-toolbelt/distinfo b/devel/py-requests-toolbelt/distinfo
index 6a5cf65a05e..acef1c0a112 100644
--- a/devel/py-requests-toolbelt/distinfo
+++ b/devel/py-requests-toolbelt/distinfo
@@ -1,6 +1,9 @@
-$NetBSD: distinfo,v 1.3 2015/11/03 03:29:15 agc Exp $
+$NetBSD: distinfo,v 1.4 2015/11/24 10:27:26 wiz Exp $
SHA1 (requests-toolbelt-0.4.0.tar.gz) = 89034149cb90c4ba825bbc8c68a590c3ad41f067
RMD160 (requests-toolbelt-0.4.0.tar.gz) = 06759883eac9d07a4a5a037746c9d36140f8396d
SHA512 (requests-toolbelt-0.4.0.tar.gz) = f3fce2f93c1152a7f42bed57bcff5910f2cb5cae27d3beea58ddfac556752c65c30e3dfd0409bcc110073d1e42edba873886c99129811115b297eb26f071577d
Size (requests-toolbelt-0.4.0.tar.gz) = 25451 bytes
+SHA1 (patch-requests__toolbelt_auth___digest__auth__compat.py) = 662f4681dff1f1795597770b50fc2c1fb6955fa0
+SHA1 (patch-requests__toolbelt_auth_guess.py) = 352acc6d4b9a98d17133257edb497743c8d09191
+SHA1 (patch-requests__toolbelt_auth_http__proxy__digest.py) = 65fe748ff7de4ebcfdc7799c4134372007d124ff
diff --git a/devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth___digest__auth__compat.py b/devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth___digest__auth__compat.py
new file mode 100644
index 00000000000..8f5672a4726
--- /dev/null
+++ b/devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth___digest__auth__compat.py
@@ -0,0 +1,47 @@
+$NetBSD: patch-requests__toolbelt_auth___digest__auth__compat.py,v 1.1 2015/11/24 10:27:26 wiz Exp $
+
+Fix authentication handlers using digest auth
+
+Requests 2.8.0 introduced a thread-safe HTTPDigestAuth class which was
+backwards incompatible for anything that attempts to work with it. This
+adds a compatibility layer for convenience based on the version of
+requests that is installed alongside the toolbelt.
+
+This also updates the HTTPProxyDigestAuth class to be threadsafe by
+utilizing the thread local storage when it is available.
+
+Closes #108
+https://github.com/sigmavirus24/requests-toolbelt/commit/d4eba75097c0f65448afb6dfab2029d3fefb02b9
+
+--- requests_toolbelt/auth/_digest_auth_compat.py.orig 2015-11-24 10:22:14.000000000 +0000
++++ requests_toolbelt/auth/_digest_auth_compat.py
+@@ -0,0 +1,29 @@
++"""Provide a compatibility layer for requests.auth.HTTPDigestAuth."""
++import requests
++
++
++class _ThreadingDescriptor(object):
++ def __init__(self, prop, default):
++ self.prop = prop
++ self.default = default
++
++ def __get__(self, obj, objtype=None):
++ return getattr(obj._thread_local, self.prop, self.default)
++
++ def __set__(self, obj, value):
++ setattr(obj._thread_local, self.prop, value)
++
++
++class _HTTPDigestAuth(requests.auth.HTTPDigestAuth):
++ init = _ThreadingDescriptor('init', True)
++ last_nonce = _ThreadingDescriptor('last_nonce', '')
++ nonce_count = _ThreadingDescriptor('nonce_count', 0)
++ chal = _ThreadingDescriptor('chal', {})
++ pos = _ThreadingDescriptor('pos', None)
++ num_401_calls = _ThreadingDescriptor('num_401_calls', 1)
++
++
++if requests.__build__ < 0x020800:
++ HTTPDigestAuth = requests.auth.HTTPDigestAuth
++else:
++ HTTPDigestAuth = _HTTPDigestAuth
diff --git a/devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth_guess.py b/devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth_guess.py
new file mode 100644
index 00000000000..d88e6a294e9
--- /dev/null
+++ b/devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth_guess.py
@@ -0,0 +1,108 @@
+$NetBSD: patch-requests__toolbelt_auth_guess.py,v 1.1 2015/11/24 10:27:26 wiz Exp $
+
+Fix authentication handlers using digest auth
+
+Requests 2.8.0 introduced a thread-safe HTTPDigestAuth class which was
+backwards incompatible for anything that attempts to work with it. This
+adds a compatibility layer for convenience based on the version of
+requests that is installed alongside the toolbelt.
+
+This also updates the HTTPProxyDigestAuth class to be threadsafe by
+utilizing the thread local storage when it is available.
+
+Closes #108
+https://github.com/sigmavirus24/requests-toolbelt/commit/d4eba75097c0f65448afb6dfab2029d3fefb02b9
+
+--- requests_toolbelt/auth/guess.py.orig 2015-03-29 04:12:14.000000000 +0000
++++ requests_toolbelt/auth/guess.py
+@@ -3,6 +3,8 @@
+ from requests import auth
+ from requests import cookies
+
++from . import _digest_auth_compat as auth_compat
++
+
+ class GuessAuth(auth.AuthBase):
+ """Guesses the auth type by the WWW-Authentication header."""
+@@ -12,38 +14,57 @@ class GuessAuth(auth.AuthBase):
+ self.auth = None
+ self.pos = None
+
++ def _handle_basic_auth_401(self, r, kwargs):
++ if self.pos is not None:
++ r.request.body.seek(self.pos)
++
++ # Consume content and release the original connection
++ # to allow our new request to reuse the same one.
++ r.content
++ r.raw.release_conn()
++ prep = r.request.copy()
++ if not hasattr(prep, '_cookies'):
++ prep._cookies = cookies.RequestsCookieJar()
++ cookies.extract_cookies_to_jar(prep._cookies, r.request, r.raw)
++ prep.prepare_cookies(prep._cookies)
++
++ self.auth = auth.HTTPBasicAuth(self.username, self.password)
++ prep = self.auth(prep)
++ _r = r.connection.send(prep, **kwargs)
++ _r.history.append(r)
++ _r.request = prep
++
++ return _r
++
++ def _handle_digest_auth_401(self, r, kwargs):
++ self.auth = auth_compat.HTTPDigestAuth(self.username, self.password)
++ try:
++ self.auth.init_per_thread_state()
++ except AttributeError:
++ # If we're not on requests 2.8.0+ this method does not exist and
++ # is not relevant.
++ pass
++
++ # Check that the attr exists because much older versions of requests
++ # set this attribute lazily. For example:
++ # https://github.com/kennethreitz/requests/blob/33735480f77891754304e7f13e3cdf83aaaa76aa/requests/auth.py#L59
++ if (hasattr(self.auth, 'num_401_calls')
++ and self.auth.num_401_calls is None):
++ self.auth.num_401_calls = 1
++ # Digest auth would resend the request by itself. We can take a
++ # shortcut here.
++ return self.auth.handle_401(r, **kwargs)
++
+ def handle_401(self, r, **kwargs):
+ """Resends a request with auth headers, if needed."""
+
+ www_authenticate = r.headers.get('www-authenticate', '').lower()
+
+ if 'basic' in www_authenticate:
+- if self.pos is not None:
+- r.request.body.seek(self.pos)
+-
+- # Consume content and release the original connection
+- # to allow our new request to reuse the same one.
+- r.content
+- r.raw.release_conn()
+- prep = r.request.copy()
+- if not hasattr(prep, '_cookies'):
+- prep._cookies = cookies.RequestsCookieJar()
+- cookies.extract_cookies_to_jar(prep._cookies, r.request, r.raw)
+- prep.prepare_cookies(prep._cookies)
+-
+- self.auth = auth.HTTPBasicAuth(self.username, self.password)
+- prep = self.auth(prep)
+- _r = r.connection.send(prep, **kwargs)
+- _r.history.append(r)
+- _r.request = prep
+-
+- return _r
++ return self._handle_basic_auth_401(r, kwargs)
+
+ if 'digest' in www_authenticate:
+- self.auth = auth.HTTPDigestAuth(self.username, self.password)
+- # Digest auth would resend the request by itself. We can take a
+- # shortcut here.
+- return self.auth.handle_401(r, **kwargs)
++ return self._handle_digest_auth_401(r, kwargs)
+
+ def __call__(self, request):
+ if self.auth is not None:
diff --git a/devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth_http__proxy__digest.py b/devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth_http__proxy__digest.py
new file mode 100644
index 00000000000..d10e1575a57
--- /dev/null
+++ b/devel/py-requests-toolbelt/patches/patch-requests__toolbelt_auth_http__proxy__digest.py
@@ -0,0 +1,68 @@
+$NetBSD: patch-requests__toolbelt_auth_http__proxy__digest.py,v 1.1 2015/11/24 10:27:26 wiz Exp $
+
+Fix authentication handlers using digest auth
+
+Requests 2.8.0 introduced a thread-safe HTTPDigestAuth class which was
+backwards incompatible for anything that attempts to work with it. This
+adds a compatibility layer for convenience based on the version of
+requests that is installed alongside the toolbelt.
+
+This also updates the HTTPProxyDigestAuth class to be threadsafe by
+utilizing the thread local storage when it is available.
+
+Closes #108
+https://github.com/sigmavirus24/requests-toolbelt/commit/d4eba75097c0f65448afb6dfab2029d3fefb02b9
+
+--- requests_toolbelt/auth/http_proxy_digest.py.orig 2015-03-29 04:12:14.000000000 +0000
++++ requests_toolbelt/auth/http_proxy_digest.py
+@@ -2,9 +2,10 @@
+ """The module containing HTTPProxyDigestAuth."""
+ import re
+
+-from requests import auth
+ from requests import cookies
+
++from . import _digest_auth_compat as auth
++
+
+ class HTTPProxyDigestAuth(auth.HTTPDigestAuth):
+ """HTTP digest authentication between proxy
+@@ -21,6 +22,30 @@ class HTTPProxyDigestAuth(auth.HTTPDiges
+ super(HTTPProxyDigestAuth, self).__init__(*args, **kwargs)
+ self.stale_rejects = 0
+
++ self.init_per_thread_state()
++
++ @property
++ def stale_rejects(self):
++ thread_local = getattr(self, '_thread_local', None)
++ if thread_local is None:
++ return self._stale_rejects
++ return thread_local.stale_rejects
++
++ @stale_rejects.setter
++ def stale_rejects(self, value):
++ thread_local = getattr(self, '_thread_local', None)
++ if thread_local is None:
++ self._stale_rejects = value
++ else:
++ thread_local.stale_rejects = value
++
++ def init_per_thread_state(self):
++ try:
++ super(HTTPProxyDigestAuth, self).init_per_thread_state()
++ except AttributeError:
++ # If we're not on requests 2.8.0+ this method does not exist
++ pass
++
+ def handle_407(self, r, **kwargs):
+ """Handle HTTP 407 only once, otherwise give up
+
+@@ -64,6 +89,7 @@ class HTTPProxyDigestAuth(auth.HTTPDiges
+ return r
+
+ def __call__(self, r):
++ self.init_per_thread_state()
+ # if we have nonce, then just use it, otherwise server will tell us
+ if self.last_nonce:
+ r.headers['Proxy-Authorization'] = self.build_digest_header(