Skip to content
Myr

urlparse(url)

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 a197309 · Browse files · 2 files+21 added−17 removed
This commit

State

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

Diff stats

2 files+21 added−17 removed

  • other:+21 added−17 removed

2 files+21 added−17 removed

modified:requests/adapters.py+18 added-2 removed
10 unmodified lines
11import os12import socket1314from .models import Response15from .auth import HTTPProxyAuth16from .packages.urllib3.poolmanager import PoolManager17from .hooks import dispatch_hook18from .compat import urlparse19from .utils import DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers20from .structures import CaseInsensitiveDict21from .packages.urllib3.exceptions import MaxRetryError22from .packages.urllib3.exceptions import TimeoutError
97 unmodified lines
120 # Run the Response hook.121 response = dispatch_hook('response', req.hooks, response)122 return response123124 def get_connection(self, url, proxies=None):125 proxies = proxies or {}126 proxy = proxies.get(urlparse(url).scheme)127128 if proxy:129 conn = poolmanager.proxy_from_url(proxy)130 else:131 conn = self.poolmanager.connection_from_url(url)132133 return conn134 # no_proxy = filter(lambda x: x.strip(), self.proxies.get('no', '').split(','))135136137138 def close(self):139 """Dispose of any internal state.140141 Currently, this just closes the PoolManager, which closes pooled142 connections.143 """144 self.poolmanager.clear()145131 def send(self, request, prefetch=True, timeout=None, verify=True, cert=None):146 def send(self, request, prefetch=True, timeout=None, verify=True, cert=None, proxies=None):147 """Sends PreparedRequest object. Returns Response object."""148134 conn = self.poolmanager.connection_from_url(request.url)149 conn = self.get_connection(request.url, proxies)150151 self.cert_verify(conn, request.url, verify, cert)152153 try:154 # Send the request.
33 unmodified lines
modified:requests/models.py+3 added-15 removed
13 unmodified lines
14import logging1516# from datetime import datetime17from io import BytesIO18from types import GeneratorType18from .hooks import dispatch_hook, default_hooks19from .structures import CaseInsensitiveDict20from .status_codes import codes2122from .auth import HTTPBasicAuth, HTTPProxyAuth23from .cookies import cookiejar_from_dict, extract_cookies_to_jar, get_cookie_header25# from .packages.urllib3.exceptions import MaxRetryError, LocationParseError26# from .packages.urllib3.exceptions import TimeoutError27# from .packages.urllib3.exceptions import SSLError as _SSLError28# from .packages.urllib3.exceptions import HTTPError as _HTTPError29# from .packages.urllib3 import connectionpool, poolmanager24from .packages.urllib3.filepost import encode_multipart_formdata3125from .exceptions import (26 ConnectionError, HTTPError, RequestException, Timeout, TooManyRedirects,27 URLRequired, SSLError, MissingSchema, InvalidSchema, InvalidURL)28from .utils import (
6 unmodified lines
35 StringIO, is_py2, chardet, json, builtin_str, urldefrag, basestring)3637REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)38CONTENT_CHUNK_SIZE = 10 * 102439ITER_CHUNK_SIZE = 10 * 10244041log = logging.getLogger(__name__)4243
6 unmodified lines
50 url = []5152 p = urlsplit(self.url)5360 # Proxies use full URLs.61 # if p.scheme in self.proxies:62 # url_base, frag = urldefrag(self.url)63 # return url_base646554 path = p.path55 if not path:56 path = '/'57
237 unmodified lines
295 def prepare_body(self, data, files):296 """Prepares the given HTTP body data."""297298 # If a generator is provided, error out.311 if isinstance(data, types.GeneratorType)299 if isinstance(data, type(_ for _ in [])):300 raise NotImplementedError('Generator bodies are not supported yet.')301302 # Nottin' on you.303 body = None
140 unmodified lines
444 gen = stream_decode_response_unicode(gen, self)445446 return gen447460 def iter_lines(self, chunk_size=10 * 1024, decode_unicode=None):448 def iter_lines(self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=None):449 """Iterates over the response data, one line at a time. This450 avoids reading the content at once into memory for large451 responses.452 """
136 unmodified lines