[Python-modules-commits] [requests] 02/08: Import requests_2.10.0.orig.tar.gz

Daniele Tricoli eriol-guest at moszumanska.debian.org
Sun May 15 17:41:25 UTC 2016


This is an automated email from the git hooks/post-receive script.

eriol-guest pushed a commit to branch master
in repository requests.

commit 5ee4efb2658ebe0fad3cc5d12271af49dd073ab3
Author: Daniele Tricoli <eriol at mornie.org>
Date:   Sun May 15 16:01:36 2016 +0200

    Import requests_2.10.0.orig.tar.gz
---
 HISTORY.rst                                    |   26 +
 LICENSE                                        |    2 +-
 PKG-INFO                                       |   96 +-
 README.rst                                     |   65 +-
 requests.egg-info/PKG-INFO                     |   96 +-
 requests.egg-info/SOURCES.txt                  |    3 +-
 requests.egg-info/requires.txt                 |    3 +
 requests/__init__.py                           |   16 +-
 requests/adapters.py                           |   52 +-
 requests/api.py                                |    6 +-
 requests/auth.py                               |   19 +
 requests/cookies.py                            |    6 +
 requests/models.py                             |   10 +-
 requests/packages/urllib3/__init__.py          |   11 +-
 requests/packages/urllib3/_collections.py      |    2 +-
 requests/packages/urllib3/connection.py        |   64 +-
 requests/packages/urllib3/connectionpool.py    |   93 +-
 requests/packages/urllib3/contrib/appengine.py |   12 +-
 requests/packages/urllib3/contrib/ntlmpool.py  |   20 +-
 requests/packages/urllib3/contrib/pyopenssl.py |   64 +-
 requests/packages/urllib3/contrib/socks.py     |  172 +++
 requests/packages/urllib3/exceptions.py        |    8 +
 requests/packages/urllib3/fields.py            |    4 +-
 requests/packages/urllib3/poolmanager.py       |   17 +-
 requests/packages/urllib3/response.py          |   38 +-
 requests/packages/urllib3/util/__init__.py     |    2 +
 requests/packages/urllib3/util/response.py     |    2 +-
 requests/packages/urllib3/util/retry.py        |   14 +-
 requests/packages/urllib3/util/ssl_.py         |   11 +-
 requests/sessions.py                           |   65 +-
 requests/status_codes.py                       |    1 +
 requests/structures.py                         |    4 +-
 requests/utils.py                              |   39 +-
 requirements.txt                               |   29 +-
 setup.cfg                                      |    3 -
 setup.py                                       |   34 +-
 test_requests.py                               | 1746 ------------------------
 37 files changed, 847 insertions(+), 2008 deletions(-)

diff --git a/HISTORY.rst b/HISTORY.rst
index f8c1a54..0eec48d 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,6 +3,32 @@
 Release History
 ---------------
 
+2.10.0 (04-29-2016)
++++++++++++++++++++
+
+**New Features**
+
+- SOCKS Proxy Support! (requires PySocks; $ pip install requests[socks])
+
+**Miscellaneous**
+
+- Updated bundled urllib3 to 1.15.1.
+
+2.9.2 (04-29-2016)
+++++++++++++++++++
+
+**Improvements**
+
+- Change built-in CaseInsensitiveDict (used for headers) to use OrderedDict
+  as its underlying datastore.
+
+**Bugfixes**
+
+- Don't use redirect_cache if allow_redirects=False
+- When passed objects that throw exceptions from ``tell()``, send them via
+  chunked transfer encoding instead of failing.
+- Raise a ProxyError for proxy related connection issues.
+
 2.9.1 (2015-12-21)
 ++++++++++++++++++
 
diff --git a/LICENSE b/LICENSE
index a103fc9..8c1dd44 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright 2015 Kenneth Reitz
+Copyright 2016 Kenneth Reitz
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
diff --git a/PKG-INFO b/PKG-INFO
index d75ebac..9fe4e72 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: requests
-Version: 2.9.1
+Version: 2.10.0
 Summary: Python HTTP for Humans.
 Home-page: http://python-requests.org
 Author: Kenneth Reitz
@@ -15,41 +15,45 @@ Description: Requests: HTTP for Humans
         .. image:: https://img.shields.io/pypi/dm/requests.svg
                 :target: https://pypi.python.org/pypi/requests
         
+        Requests is the only *Non-GMO* HTTP library for Python, safe for human
+        consumption.
         
+        **Warning:** Recreational use of other HTTP libraries may result in dangerous side-effects,
+        including: security vulnerabilities, verbose code, reinventing the wheel,
+        constantly reading documentation, depression, headaches, or even death.
         
-        
-        Requests is an Apache2 Licensed HTTP library, written in Python, for human
-        beings.
-        
-        Most existing Python modules for sending HTTP requests are extremely
-        verbose and cumbersome. Python's builtin urllib2 module provides most of
-        the HTTP capabilities you should need, but the api is thoroughly broken.
-        It requires an enormous amount of work (even method overrides) to
-        perform the simplest of tasks.
-        
-        Things shouldn't be this way. Not in Python.
+        Behold, the power of Requests:
         
         .. code-block:: python
         
-            >>> r = requests.get('https://api.github.com', auth=('user', 'pass'))
+            >>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
             >>> r.status_code
-            204
+            200
             >>> r.headers['content-type']
-            'application/json'
+            'application/json; charset=utf8'
+            >>> r.encoding
+            'utf-8'
             >>> r.text
-            ...
+            u'{"type":"User"...'
+            >>> r.json()
+            {u'disk_usage': 368627, u'private_gists': 484, ...}
         
-        See `the same code, without Requests <https://gist.github.com/973705>`_.
+        See `the similar code, sans Requests <https://gist.github.com/973705>`_.
         
-        Requests allow you to send HTTP/1.1 requests. You can add headers, form data,
-        multipart files, and parameters with simple Python dictionaries, and access the
-        response data in the same way. It's powered by httplib and `urllib3
-        <https://github.com/shazow/urllib3>`_, but it does all the hard work and crazy
-        hacks for you.
+        Requests allows you to send *organic, grass-fed* HTTP/1.1 requests, without the
+        need for manual labor. There's no need to manually add query strings to your
+        URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling
+        are 100% automatic, powered by `urllib3 <https://github.com/shazow/urllib3>`_,
+        which is embedded within Requests.
         
+        Besides, all the cool kids are doing it. Requests is one of the most
+        downloaded Python packages of all time, pulling in over 7,000,000 downloads
+        every month. You don't want to be left out!
+        
+        Feature Support
+        ---------------
         
-        Features
-        --------
+        Requests is ready for today's web.
         
         - International Domains and URLs
         - Keep-Alive & Connection Pooling
@@ -58,12 +62,17 @@ Description: Requests: HTTP for Humans
         - Basic/Digest Authentication
         - Elegant Key/Value Cookies
         - Automatic Decompression
+        - Automatic Content Decoding
         - Unicode Response Bodies
         - Multipart File Uploads
+        - HTTP(S) Proxy Support
         - Connection Timeouts
+        - Streaming Downloads
+        - ``.netrc`` Support
+        - Chunked Requests
         - Thread-safety
-        - HTTP(S) proxy support
         
+        Requests supports Python 2.6 — 3.5, and runs great on PyPy.
         
         Installation
         ------------
@@ -73,16 +82,18 @@ Description: Requests: HTTP for Humans
         .. code-block:: bash
         
             $ pip install requests
+            ✨🍰✨
         
+        Satisfaction, guaranteed.
         
         Documentation
         -------------
         
-        Documentation is available at http://docs.python-requests.org/.
+        Fantastic documentation is available at http://docs.python-requests.org/, for a limited time only.
         
         
-        Contribute
-        ----------
+        How to Contribute
+        -----------------
         
         #. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. There is a `Contributor Friendly`_ tag for issues that should be ideal for people who are not very familiar with the codebase yet.
         #. Fork `the repository`_ on GitHub to start making your changes to the **master** branch (or branch off of it).
@@ -99,6 +110,32 @@ Description: Requests: HTTP for Humans
         Release History
         ---------------
         
+        2.10.0 (04-29-2016)
+        +++++++++++++++++++
+        
+        **New Features**
+        
+        - SOCKS Proxy Support! (requires PySocks; $ pip install requests[socks])
+        
+        **Miscellaneous**
+        
+        - Updated bundled urllib3 to 1.15.1.
+        
+        2.9.2 (04-29-2016)
+        ++++++++++++++++++
+        
+        **Improvements**
+        
+        - Change built-in CaseInsensitiveDict (used for headers) to use OrderedDict
+          as its underlying datastore.
+        
+        **Bugfixes**
+        
+        - Don't use redirect_cache if allow_redirects=False
+        - When passed objects that throw exceptions from ``tell()``, send them via
+          chunked transfer encoding instead of failing.
+        - Raise a ProxyError for proxy related connection issues.
+        
         2.9.1 (2015-12-21)
         ++++++++++++++++++
         
@@ -1231,8 +1268,11 @@ Classifier: Intended Audience :: Developers
 Classifier: Natural Language :: English
 Classifier: License :: OSI Approved :: Apache Software License
 Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
 Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
diff --git a/README.rst b/README.rst
index 99d30e7..9fe548d 100644
--- a/README.rst
+++ b/README.rst
@@ -7,41 +7,45 @@ Requests: HTTP for Humans
 .. image:: https://img.shields.io/pypi/dm/requests.svg
         :target: https://pypi.python.org/pypi/requests
 
+Requests is the only *Non-GMO* HTTP library for Python, safe for human
+consumption.
 
+**Warning:** Recreational use of other HTTP libraries may result in dangerous side-effects,
+including: security vulnerabilities, verbose code, reinventing the wheel,
+constantly reading documentation, depression, headaches, or even death.
 
-
-Requests is an Apache2 Licensed HTTP library, written in Python, for human
-beings.
-
-Most existing Python modules for sending HTTP requests are extremely
-verbose and cumbersome. Python's builtin urllib2 module provides most of
-the HTTP capabilities you should need, but the api is thoroughly broken.
-It requires an enormous amount of work (even method overrides) to
-perform the simplest of tasks.
-
-Things shouldn't be this way. Not in Python.
+Behold, the power of Requests:
 
 .. code-block:: python
 
-    >>> r = requests.get('https://api.github.com', auth=('user', 'pass'))
+    >>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
     >>> r.status_code
-    204
+    200
     >>> r.headers['content-type']
-    'application/json'
+    'application/json; charset=utf8'
+    >>> r.encoding
+    'utf-8'
     >>> r.text
-    ...
+    u'{"type":"User"...'
+    >>> r.json()
+    {u'disk_usage': 368627, u'private_gists': 484, ...}
+
+See `the similar code, sans Requests <https://gist.github.com/973705>`_.
 
-See `the same code, without Requests <https://gist.github.com/973705>`_.
+Requests allows you to send *organic, grass-fed* HTTP/1.1 requests, without the
+need for manual labor. There's no need to manually add query strings to your
+URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling
+are 100% automatic, powered by `urllib3 <https://github.com/shazow/urllib3>`_,
+which is embedded within Requests.
 
-Requests allow you to send HTTP/1.1 requests. You can add headers, form data,
-multipart files, and parameters with simple Python dictionaries, and access the
-response data in the same way. It's powered by httplib and `urllib3
-<https://github.com/shazow/urllib3>`_, but it does all the hard work and crazy
-hacks for you.
+Besides, all the cool kids are doing it. Requests is one of the most
+downloaded Python packages of all time, pulling in over 7,000,000 downloads
+every month. You don't want to be left out!
 
+Feature Support
+---------------
 
-Features
---------
+Requests is ready for today's web.
 
 - International Domains and URLs
 - Keep-Alive & Connection Pooling
@@ -50,12 +54,17 @@ Features
 - Basic/Digest Authentication
 - Elegant Key/Value Cookies
 - Automatic Decompression
+- Automatic Content Decoding
 - Unicode Response Bodies
 - Multipart File Uploads
+- HTTP(S) Proxy Support
 - Connection Timeouts
+- Streaming Downloads
+- ``.netrc`` Support
+- Chunked Requests
 - Thread-safety
-- HTTP(S) proxy support
 
+Requests supports Python 2.6 — 3.5, and runs great on PyPy.
 
 Installation
 ------------
@@ -65,16 +74,18 @@ To install Requests, simply:
 .. code-block:: bash
 
     $ pip install requests
+    ✨🍰✨
 
+Satisfaction, guaranteed.
 
 Documentation
 -------------
 
-Documentation is available at http://docs.python-requests.org/.
+Fantastic documentation is available at http://docs.python-requests.org/, for a limited time only.
 
 
-Contribute
-----------
+How to Contribute
+-----------------
 
 #. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. There is a `Contributor Friendly`_ tag for issues that should be ideal for people who are not very familiar with the codebase yet.
 #. Fork `the repository`_ on GitHub to start making your changes to the **master** branch (or branch off of it).
diff --git a/requests.egg-info/PKG-INFO b/requests.egg-info/PKG-INFO
index d75ebac..9fe4e72 100644
--- a/requests.egg-info/PKG-INFO
+++ b/requests.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: requests
-Version: 2.9.1
+Version: 2.10.0
 Summary: Python HTTP for Humans.
 Home-page: http://python-requests.org
 Author: Kenneth Reitz
@@ -15,41 +15,45 @@ Description: Requests: HTTP for Humans
         .. image:: https://img.shields.io/pypi/dm/requests.svg
                 :target: https://pypi.python.org/pypi/requests
         
+        Requests is the only *Non-GMO* HTTP library for Python, safe for human
+        consumption.
         
+        **Warning:** Recreational use of other HTTP libraries may result in dangerous side-effects,
+        including: security vulnerabilities, verbose code, reinventing the wheel,
+        constantly reading documentation, depression, headaches, or even death.
         
-        
-        Requests is an Apache2 Licensed HTTP library, written in Python, for human
-        beings.
-        
-        Most existing Python modules for sending HTTP requests are extremely
-        verbose and cumbersome. Python's builtin urllib2 module provides most of
-        the HTTP capabilities you should need, but the api is thoroughly broken.
-        It requires an enormous amount of work (even method overrides) to
-        perform the simplest of tasks.
-        
-        Things shouldn't be this way. Not in Python.
+        Behold, the power of Requests:
         
         .. code-block:: python
         
-            >>> r = requests.get('https://api.github.com', auth=('user', 'pass'))
+            >>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
             >>> r.status_code
-            204
+            200
             >>> r.headers['content-type']
-            'application/json'
+            'application/json; charset=utf8'
+            >>> r.encoding
+            'utf-8'
             >>> r.text
-            ...
+            u'{"type":"User"...'
+            >>> r.json()
+            {u'disk_usage': 368627, u'private_gists': 484, ...}
         
-        See `the same code, without Requests <https://gist.github.com/973705>`_.
+        See `the similar code, sans Requests <https://gist.github.com/973705>`_.
         
-        Requests allow you to send HTTP/1.1 requests. You can add headers, form data,
-        multipart files, and parameters with simple Python dictionaries, and access the
-        response data in the same way. It's powered by httplib and `urllib3
-        <https://github.com/shazow/urllib3>`_, but it does all the hard work and crazy
-        hacks for you.
+        Requests allows you to send *organic, grass-fed* HTTP/1.1 requests, without the
+        need for manual labor. There's no need to manually add query strings to your
+        URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling
+        are 100% automatic, powered by `urllib3 <https://github.com/shazow/urllib3>`_,
+        which is embedded within Requests.
         
+        Besides, all the cool kids are doing it. Requests is one of the most
+        downloaded Python packages of all time, pulling in over 7,000,000 downloads
+        every month. You don't want to be left out!
+        
+        Feature Support
+        ---------------
         
-        Features
-        --------
+        Requests is ready for today's web.
         
         - International Domains and URLs
         - Keep-Alive & Connection Pooling
@@ -58,12 +62,17 @@ Description: Requests: HTTP for Humans
         - Basic/Digest Authentication
         - Elegant Key/Value Cookies
         - Automatic Decompression
+        - Automatic Content Decoding
         - Unicode Response Bodies
         - Multipart File Uploads
+        - HTTP(S) Proxy Support
         - Connection Timeouts
+        - Streaming Downloads
+        - ``.netrc`` Support
+        - Chunked Requests
         - Thread-safety
-        - HTTP(S) proxy support
         
+        Requests supports Python 2.6 — 3.5, and runs great on PyPy.
         
         Installation
         ------------
@@ -73,16 +82,18 @@ Description: Requests: HTTP for Humans
         .. code-block:: bash
         
             $ pip install requests
+            ✨🍰✨
         
+        Satisfaction, guaranteed.
         
         Documentation
         -------------
         
-        Documentation is available at http://docs.python-requests.org/.
+        Fantastic documentation is available at http://docs.python-requests.org/, for a limited time only.
         
         
-        Contribute
-        ----------
+        How to Contribute
+        -----------------
         
         #. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. There is a `Contributor Friendly`_ tag for issues that should be ideal for people who are not very familiar with the codebase yet.
         #. Fork `the repository`_ on GitHub to start making your changes to the **master** branch (or branch off of it).
@@ -99,6 +110,32 @@ Description: Requests: HTTP for Humans
         Release History
         ---------------
         
+        2.10.0 (04-29-2016)
+        +++++++++++++++++++
+        
+        **New Features**
+        
+        - SOCKS Proxy Support! (requires PySocks; $ pip install requests[socks])
+        
+        **Miscellaneous**
+        
+        - Updated bundled urllib3 to 1.15.1.
+        
+        2.9.2 (04-29-2016)
+        ++++++++++++++++++
+        
+        **Improvements**
+        
+        - Change built-in CaseInsensitiveDict (used for headers) to use OrderedDict
+          as its underlying datastore.
+        
+        **Bugfixes**
+        
+        - Don't use redirect_cache if allow_redirects=False
+        - When passed objects that throw exceptions from ``tell()``, send them via
+          chunked transfer encoding instead of failing.
+        - Raise a ProxyError for proxy related connection issues.
+        
         2.9.1 (2015-12-21)
         ++++++++++++++++++
         
@@ -1231,8 +1268,11 @@ Classifier: Intended Audience :: Developers
 Classifier: Natural Language :: English
 Classifier: License :: OSI Approved :: Apache Software License
 Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
 Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
diff --git a/requests.egg-info/SOURCES.txt b/requests.egg-info/SOURCES.txt
index f769d3b..d288508 100644
--- a/requests.egg-info/SOURCES.txt
+++ b/requests.egg-info/SOURCES.txt
@@ -4,9 +4,7 @@ MANIFEST.in
 NOTICE
 README.rst
 requirements.txt
-setup.cfg
 setup.py
-test_requests.py
 requests/__init__.py
 requests/adapters.py
 requests/api.py
@@ -81,6 +79,7 @@ requests/packages/urllib3/contrib/__init__.py
 requests/packages/urllib3/contrib/appengine.py
 requests/packages/urllib3/contrib/ntlmpool.py
 requests/packages/urllib3/contrib/pyopenssl.py
+requests/packages/urllib3/contrib/socks.py
 requests/packages/urllib3/packages/__init__.py
 requests/packages/urllib3/packages/ordered_dict.py
 requests/packages/urllib3/packages/six.py
diff --git a/requests.egg-info/requires.txt b/requests.egg-info/requires.txt
index 34ddab5..1d7b727 100644
--- a/requests.egg-info/requires.txt
+++ b/requests.egg-info/requires.txt
@@ -3,3 +3,6 @@
 pyOpenSSL>=0.13
 ndg-httpsclient
 pyasn1
+
+[socks]
+PySocks>=1.5.6
diff --git a/requests/__init__.py b/requests/__init__.py
index bd5b5b9..82c0f78 100644
--- a/requests/__init__.py
+++ b/requests/__init__.py
@@ -36,17 +36,17 @@ usage:
 The other HTTP methods are supported - see `requests.api`. Full documentation
 is at <http://python-requests.org>.
 
-:copyright: (c) 2015 by Kenneth Reitz.
+:copyright: (c) 2016 by Kenneth Reitz.
 :license: Apache 2.0, see LICENSE for more details.
 
 """
 
 __title__ = 'requests'
-__version__ = '2.9.1'
-__build__ = 0x020901
+__version__ = '2.10.0'
+__build__ = 0x021000
 __author__ = 'Kenneth Reitz'
 __license__ = 'Apache 2.0'
-__copyright__ = 'Copyright 2015 Kenneth Reitz'
+__copyright__ = 'Copyright 2016 Kenneth Reitz'
 
 # Attempt to enable urllib3's SNI support, if possible
 try:
@@ -55,6 +55,12 @@ try:
 except ImportError:
     pass
 
+import warnings
+
+# urllib3's DependencyWarnings should be silenced.
+from .packages.urllib3.exceptions import DependencyWarning
+warnings.simplefilter('ignore', DependencyWarning)
+
 from . import utils
 from .models import Request, Response, PreparedRequest
 from .api import request, get, head, post, patch, put, delete, options
@@ -63,7 +69,7 @@ from .status_codes import codes
 from .exceptions import (
     RequestException, Timeout, URLRequired,
     TooManyRedirects, HTTPError, ConnectionError,
-    FileModeWarning,
+    FileModeWarning, ConnectTimeout, ReadTimeout
 )
 
 # Set default logging handler to avoid "No handler found" warnings.
diff --git a/requests/adapters.py b/requests/adapters.py
index 6266d5b..23e448f 100644
--- a/requests/adapters.py
+++ b/requests/adapters.py
@@ -19,7 +19,7 @@ from .packages.urllib3.util.retry import Retry
 from .compat import urlparse, basestring
 from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,
                     prepend_scheme_if_needed, get_auth_from_url, urldefragauth,
-                    select_proxy)
+                    select_proxy, to_native_string)
 from .structures import CaseInsensitiveDict
 from .packages.urllib3.exceptions import ClosedPoolError
 from .packages.urllib3.exceptions import ConnectTimeoutError
@@ -33,9 +33,15 @@ from .packages.urllib3.exceptions import SSLError as _SSLError
 from .packages.urllib3.exceptions import ResponseError
 from .cookies import extract_cookies_to_jar
 from .exceptions import (ConnectionError, ConnectTimeout, ReadTimeout, SSLError,
-                         ProxyError, RetryError)
+                         ProxyError, RetryError, InvalidSchema)
 from .auth import _basic_auth_str
 
+try:
+    from .packages.urllib3.contrib.socks import SOCKSProxyManager
+except ImportError:
+    def SOCKSProxyManager(*args, **kwargs):
+        raise InvalidSchema("Missing dependencies for SOCKS support.")
+
 DEFAULT_POOLBLOCK = False
 DEFAULT_POOLSIZE = 10
 DEFAULT_RETRIES = 0
@@ -65,7 +71,7 @@ class HTTPAdapter(BaseAdapter):
 
     :param pool_connections: The number of urllib3 connection pools to cache.
     :param pool_maxsize: The maximum number of connections to save in the pool.
-    :param int max_retries: The maximum number of retries each connection
+    :param max_retries: The maximum number of retries each connection
         should attempt. Note, this applies only to failed DNS lookups, socket
         connections and connection timeouts, never to requests where data has
         made it to the server. By default, Requests does not retry failed
@@ -149,9 +155,22 @@ class HTTPAdapter(BaseAdapter):
         :param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager.
         :returns: ProxyManager
         """
-        if not proxy in self.proxy_manager:
+        if proxy in self.proxy_manager:
+            manager = self.proxy_manager[proxy]
+        elif proxy.lower().startswith('socks'):
+            username, password = get_auth_from_url(proxy)
+            manager = self.proxy_manager[proxy] = SOCKSProxyManager(
+                proxy,
+                username=username,
+                password=password,
+                num_pools=self._pool_connections,
+                maxsize=self._pool_maxsize,
+                block=self._pool_block,
+                **proxy_kwargs
+            )
+        else:
             proxy_headers = self.proxy_headers(proxy)
-            self.proxy_manager[proxy] = proxy_from_url(
+            manager = self.proxy_manager[proxy] = proxy_from_url(
                 proxy,
                 proxy_headers=proxy_headers,
                 num_pools=self._pool_connections,
@@ -159,7 +178,7 @@ class HTTPAdapter(BaseAdapter):
                 block=self._pool_block,
                 **proxy_kwargs)
 
-        return self.proxy_manager[proxy]
+        return manager
 
     def cert_verify(self, conn, url, verify, cert):
         """Verify a SSL certificate. This method should not be called from user
@@ -264,10 +283,12 @@ class HTTPAdapter(BaseAdapter):
     def close(self):
         """Disposes of any internal state.
 
-        Currently, this just closes the PoolManager, which closes pooled
-        connections.
+        Currently, this closes the PoolManager and any active ProxyManager,
+        which closes any pooled connections.
         """
         self.poolmanager.clear()
+        for proxy in self.proxy_manager.values():
+            proxy.clear()
 
     def request_url(self, request, proxies):
         """Obtain the url to use when making the final request.
@@ -284,10 +305,16 @@ class HTTPAdapter(BaseAdapter):
         """
         proxy = select_proxy(request.url, proxies)
         scheme = urlparse(request.url).scheme
-        if proxy and scheme != 'https':
+
+        is_proxied_http_request = (proxy and scheme != 'https')
+        using_socks_proxy = False
+        if proxy:
+            proxy_scheme = urlparse(proxy).scheme.lower()
+            using_socks_proxy = proxy_scheme.startswith('socks')
+
+        url = request.path_url
+        if is_proxied_http_request and not using_socks_proxy:
             url = urldefragauth(request.url)
-        else:
-            url = request.path_url
 
         return url
 
@@ -434,6 +461,9 @@ class HTTPAdapter(BaseAdapter):
             if isinstance(e.reason, ResponseError):
                 raise RetryError(e, request=request)
 
+            if isinstance(e.reason, _ProxyError):
+                raise ProxyError(e, request=request)
+
             raise ConnectionError(e, request=request)
 
         except ClosedPoolError as e:
diff --git a/requests/api.py b/requests/api.py
index b21a1a4..c2068d0 100644
--- a/requests/api.py
+++ b/requests/api.py
@@ -24,7 +24,11 @@ def request(method, url, **kwargs):
     :param json: (optional) json data to send in the body of the :class:`Request`.
     :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
     :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
-    :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': ('filename', fileobj)}``) for multipart encoding upload.
+    :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
+        ``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
+        or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
+        defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
+        to add for the file.
     :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
     :param timeout: (optional) How long to wait for the server to send data
         before giving up, as a float, or a :ref:`(connect timeout, read
diff --git a/requests/auth.py b/requests/auth.py
index 2af55fb..73f8e9d 100644
--- a/requests/auth.py
+++ b/requests/auth.py
@@ -47,6 +47,15 @@ class HTTPBasicAuth(AuthBase):
         self.username = username
         self.password = password
 
+    def __eq__(self, other):
+        return all([
+            self.username == getattr(other, 'username', None),
+            self.password == getattr(other, 'password', None)
+        ])
+
+    def __ne__(self, other):
+        return not self == other
+
     def __call__(self, r):
         r.headers['Authorization'] = _basic_auth_str(self.username, self.password)
         return r
@@ -84,6 +93,7 @@ class HTTPDigestAuth(AuthBase):
         qop = self._thread_local.chal.get('qop')
         algorithm = self._thread_local.chal.get('algorithm')
         opaque = self._thread_local.chal.get('opaque')
+        hash_utf8 = None
 
         if algorithm is None:
             _algorithm = 'MD5'
@@ -221,3 +231,12 @@ class HTTPDigestAuth(AuthBase):
         self._thread_local.num_401_calls = 1
 
         return r
+
+    def __eq__(self, other):
+        return all([
+            self.username == getattr(other, 'username', None),
+            self.password == getattr(other, 'password', None)
+        ])
+
+    def __ne__(self, other):
+        return not self == other
diff --git a/requests/cookies.py b/requests/cookies.py
index b85fd2b..eee5168 100644
--- a/requests/cookies.py
+++ b/requests/cookies.py
@@ -277,6 +277,12 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
                 dictionary[cookie.name] = cookie.value
         return dictionary
 
+    def __contains__(self, name):
+        try:
+            return super(RequestsCookieJar, self).__contains__(name)
+        except CookieConflictError:
+            return True
+
     def __getitem__(self, name):
         """Dict-like __getitem__() for compatibility with client code. Throws
         exception if there are more than one cookie with name. In that case,
diff --git a/requests/models.py b/requests/models.py
index 4bcbc54..fe4bec1 100644
--- a/requests/models.py
+++ b/requests/models.py
@@ -103,8 +103,10 @@ class RequestEncodingMixin(object):
         """Build the body for a multipart/form-data request.
 
         Will successfully encode files when passed as a dict or a list of
-        2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
+        tuples. Order is retained if data is a list of tuples but arbitrary
         if parameters are supplied as a dict.
+        The tuples may be 2-tuples (filename, fileobj), 3-tuples (filename, fileobj, contentype)
+        or 4-tuples (filename, fileobj, contentype, custom_headers).
 
         """
         if (not files):
@@ -463,9 +465,11 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
 
     def prepare_content_length(self, body):
         if hasattr(body, 'seek') and hasattr(body, 'tell'):
+            curr_pos = body.tell()
             body.seek(0, 2)
-            self.headers['Content-Length'] = builtin_str(body.tell())
-            body.seek(0, 0)
+            end_pos = body.tell()
+            self.headers['Content-Length'] = builtin_str(max(0, end_pos - curr_pos))
+            body.seek(curr_pos, 0)
         elif body is not None:
             l = super_len(body)
             if l:
diff --git a/requests/packages/urllib3/__init__.py b/requests/packages/urllib3/__init__.py
index e43991a..7366899 100644
--- a/requests/packages/urllib3/__init__.py
+++ b/requests/packages/urllib3/__init__.py
@@ -32,7 +32,7 @@ except ImportError:
 
 __author__ = 'Andrey Petrov (andrey.petrov at shazow.net)'
 __license__ = 'MIT'
-__version__ = '1.13.1'
+__version__ = '1.15.1'
 
 __all__ = (
     'HTTPConnectionPool',
@@ -68,22 +68,25 @@ def add_stderr_logger(level=logging.DEBUG):
     handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
     logger.addHandler(handler)
     logger.setLevel(level)
-    logger.debug('Added a stderr logging handler to logger: %s' % __name__)
+    logger.debug('Added a stderr logging handler to logger: %s', __name__)
     return handler
 
 # ... Clean up.
 del NullHandler
 
 
+# All warning filters *must* be appended unless you're really certain that they
+# shouldn't be: otherwise, it's very hard for users to use most Python
+# mechanisms to silence them.
 # SecurityWarning's always go off by default.
 warnings.simplefilter('always', exceptions.SecurityWarning, append=True)
 # SubjectAltNameWarning's should go off once per host
-warnings.simplefilter('default', exceptions.SubjectAltNameWarning)
+warnings.simplefilter('default', exceptions.SubjectAltNameWarning, append=True)
 # InsecurePlatformWarning's don't vary between requests, so we keep it default.
 warnings.simplefilter('default', exceptions.InsecurePlatformWarning,
                       append=True)
 # SNIMissingWarnings should go off only once.
-warnings.simplefilter('default', exceptions.SNIMissingWarning)
+warnings.simplefilter('default', exceptions.SNIMissingWarning, append=True)
 
 
 def disable_warnings(category=exceptions.HTTPWarning):
diff --git a/requests/packages/urllib3/_collections.py b/requests/packages/urllib3/_collections.py
index 67f3ce9..77cee01 100644
--- a/requests/packages/urllib3/_collections.py
+++ b/requests/packages/urllib3/_collections.py
@@ -134,7 +134,7 @@ class HTTPHeaderDict(MutableMapping):
 
     def __init__(self, headers=None, **kwargs):
         super(HTTPHeaderDict, self).__init__()
-        self._container = {}
+        self._container = OrderedDict()
         if headers is not None:
             if isinstance(headers, HTTPHeaderDict):
                 self._copy_from(headers)
diff --git a/requests/packages/urllib3/connection.py b/requests/packages/urllib3/connection.py
index 1e4cd41..5ce0080 100644
--- a/requests/packages/urllib3/connection.py
+++ b/requests/packages/urllib3/connection.py
@@ -1,5 +1,6 @@
 from __future__ import absolute_import
 import datetime
+import logging
 import os
 import sys
 import socket
@@ -38,7 +39,7 @@ from .exceptions import (
     SubjectAltNameWarning,
     SystemTimeWarning,
 )
-from .packages.ssl_match_hostname import match_hostname
+from .packages.ssl_match_hostname import match_hostname, CertificateError
 
 from .util.ssl_ import (
     resolve_cert_reqs,
@@ -50,6 +51,10 @@ from .util.ssl_ import (
 
 from .util import connection
 
+from ._collections import HTTPHeaderDict
+
+log = logging.getLogger(__name__)
+
 port_by_scheme = {
     'http': 80,
     'https': 443,
@@ -162,6 +167,38 @@ class HTTPConnection(_HTTPConnection, object):
         conn = self._new_conn()
         self._prepare_conn(conn)
 
+    def request_chunked(self, method, url, body=None, headers=None):
+        """
+        Alternative to the common request method, which sends the
+        body with chunked encoding and not as one block
+        """
+        headers = HTTPHeaderDict(headers if headers is not None else {})
+        skip_accept_encoding = 'accept-encoding' in headers
+        self.putrequest(method, url, skip_accept_encoding=skip_accept_encoding)
+        for header, value in headers.items():
+            self.putheader(header, value)
+        if 'transfer-encoding' not in headers:
+            self.putheader('Transfer-Encoding', 'chunked')
+        self.endheaders()
+
+        if body is not None:
+            stringish_types = six.string_types + (six.binary_type,)
+            if isinstance(body, stringish_types):
+                body = (body,)
+            for chunk in body:
+                if not chunk:
+                    continue
+                if not isinstance(chunk, six.binary_type):
+                    chunk = chunk.encode('utf8')
+                len_str = hex(len(chunk))[2:]
+                self.send(len_str.encode('utf-8'))
+                self.send(b'\r\n')
+                self.send(chunk)
+                self.send(b'\r\n')
+
+        # After the if clause, to always have a closed body
+        self.send(b'0\r\n\r\n')
+
 
 class HTTPSConnection(HTTPConnection):
     default_port = port_by_scheme['https']
@@ -265,21 +302,26 @@ class VerifiedHTTPSConnection(HTTPSConnection):
                     'for details.)'.format(hostname)),
                     SubjectAltNameWarning
                 )
-
-            # In case the hostname is an IPv6 address, strip the square
-            # brackets from it before using it to validate. This is because
-            # a certificate with an IPv6 address in it won't have square
-            # brackets around that address. Sadly, match_hostname won't do this
-            # for us: it expects the plain host part without any extra work
-            # that might have been done to make it palatable to httplib.
-            asserted_hostname = self.assert_hostname or hostname
-            asserted_hostname = asserted_hostname.strip('[]')
-            match_hostname(cert, asserted_hostname)
+            _match_hostname(cert, self.assert_hostname or hostname)
 
         self.is_verified = (resolved_cert_reqs == ssl.CERT_REQUIRED or
                             self.assert_fingerprint is not None)
 
 
+def _match_hostname(cert, asserted_hostname):
+    try:
+        match_hostname(cert, asserted_hostname)
+    except CertificateError as e:
+        log.error(
+            'Certificate did not match expected hostname: %s. '
+            'Certificate: %s', asserted_hostname, cert
+        )
+        # Add cert to exception and reraise so client code can inspect
+        # the cert when catching the exception, if they want to
+        e._peer_cert = cert
... 3100 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/requests.git



More information about the Python-modules-commits mailing list