Skip to content
Myr

SSL support!

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 9a1a413 · Browse files · 1 file+36 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+36 added−3 removed

  • other:+36 added−3 removed

1 file+36 added−3 removed

modified:requests/models.py+36 added-3 removed
5 unmodified lines
67This module contains the primary objects that power Requests.8"""910import os11import urllib12import zlib1314from urlparse import urlparse, urlunparse, urljoin, urlsplit
11 unmodified lines
26from .packages.urllib3 import connectionpool, poolmanager27from .packages.urllib3.filepost import encode_multipart_formdata28from .exceptions import (29 ConnectionError, HTTPError, RequestException, Timeout, TooManyRedirects,29 URLRequired)30 URLRequired, SSLError)31from .utils import (32 get_encoding_from_headers, stream_decode_response_unicode,33 decode_gzip, stream_decode_gzip, guess_filename, requote_path)34
21 unmodified lines
56 allow_redirects=False,57 proxies=None,58 hooks=None,59 config=None,59 _poolmanager=None):60 _poolmanager=None,61 verify=None):6263 #: Float describes the timeout of the request.64 # (Use socket.setdefaulttimeout() as fallback)65 self.timeout = timeout
53 unmodified lines
119120 #: Session.121 self.session = None122123 #: SSL Verification.124 self.verify = verify125126 if headers:127 headers = CaseInsensitiveDict(self.headers)128 else:129 headers = CaseInsensitiveDict()
116 unmodified lines
246 config=self.config,247 timeout=self.timeout,248 _poolmanager=self._poolmanager,249 proxies = self.proxies,250 verify = self.verify251 )252253 request.send()254 cookies.update(request.response.cookies)
175 unmodified lines
430 conn = self._poolmanager.connection_from_url(url)431 else:432 conn = connectionpool.connection_from_url(url)433434 if url.startswith('https') and self.verify:435436 cert_loc = None437438 # Allow self-specified cert location.439 if self.verify is not True:440 cert_loc = self.verify441442443 # Look for configuration.444 if not cert_loc:445 cert_loc = os.environ.get('REQUESTS_CA_BUNDLE')446447 # Curl compatiblity.448 if not cert_loc:449 cert_loc = os.environ.get('CURL_CA_BUNDLE')450451 # Use the awesome certifi list.452 if not cert_loc:453 cert_loc = __import__('certifi').where()454455 conn.cert_reqs = 'CERT_REQUIRED'456 conn.ca_certs = cert_loc457458 if not self.sent or anyway:459460 if self.cookies:461
34 unmodified lines
496 except MaxRetryError, e:497 raise ConnectionError(e)498499 except (_SSLError, _HTTPError), e:500 if self.verify and isinstance(e, _SSLError):501 raise SSLError(e)502503 raise Timeout('Request timed out.')504505 except RequestException, e:506 if self.config.get('safe_mode', False):474 # In safe mode, catch the exception and attach it to 507 # In safe mode, catch the exception and attach it to508 # a blank urllib3.HTTPResponse object.509 r = HTTPResponse()510 r.error = e511 else:
230 unmodified lines