diff options
author | Christopher Baines <mail@cbaines.net> | 2015-12-22 13:47:07 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2015-12-22 13:48:06 +0000 |
commit | 79f51e45f74dd32f9c1a103150ded9d575f5f94c (patch) | |
tree | adcea8da78181c97b46d4483657877b2b348833a /requests/adapters.py | |
parent | 59759b30c8a8f23377afe562a44ddc893dbbb833 (diff) | |
parent | 08c16e06ad11c6fcb26f4ca1ea3f11093598092f (diff) | |
download | python-requests-79f51e45f74dd32f9c1a103150ded9d575f5f94c.tar python-requests-79f51e45f74dd32f9c1a103150ded9d575f5f94c.tar.gz |
change version to 2.9.1-1 (UNRELEASED)
New upstream release 2.9.1
Diffstat (limited to 'requests/adapters.py')
-rw-r--r-- | requests/adapters.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/requests/adapters.py b/requests/adapters.py index 7682db0..6266d5b 100644 --- a/requests/adapters.py +++ b/requests/adapters.py @@ -8,6 +8,7 @@ This module contains the transport adapters that Requests uses to define and maintain connections. """ +import os.path import socket from .models import Response @@ -107,7 +108,7 @@ class HTTPAdapter(BaseAdapter): def __setstate__(self, state): # Can't handle by adding 'proxy_manager' to self.__attrs__ because - # because self.poolmanager uses a lambda function, which isn't pickleable. + # self.poolmanager uses a lambda function, which isn't pickleable. self.proxy_manager = {} self.config = {} @@ -185,10 +186,15 @@ class HTTPAdapter(BaseAdapter): raise Exception("Could not find a suitable SSL CA certificate bundle.") conn.cert_reqs = 'CERT_REQUIRED' - conn.ca_certs = cert_loc + + if not os.path.isdir(cert_loc): + conn.ca_certs = cert_loc + else: + conn.ca_cert_dir = cert_loc else: conn.cert_reqs = 'CERT_NONE' conn.ca_certs = None + conn.ca_cert_dir = None if cert: if not isinstance(cert, basestring): @@ -394,7 +400,15 @@ class HTTPAdapter(BaseAdapter): low_conn.send(b'\r\n') low_conn.send(b'0\r\n\r\n') - r = low_conn.getresponse() + # Receive the response from the server + try: + # For Python 2.7+ versions, use buffering of HTTP + # responses + r = low_conn.getresponse(buffering=True) + except TypeError: + # For compatibility with Python 2.6 versions and back + r = low_conn.getresponse() + resp = HTTPResponse.from_httplib( r, pool=conn, |