Skip to content
Myr

SCHEMAS

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 cf37f63 · Browse files · 3 files+16 added−16 removed
This commit

State

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

Diff stats

3 files+16 added−16 removed

  • other:+16 added−16 removed

3 files+16 added−16 removed

modified:requests/defaults.py+4 added
17 unmodified lines
18:pool_maxsize: The maximium size of an HTTP connection pool.19:pool_connections: The number of active HTTP connection pools to use.20"""2122SCHEMAS = ['http', 'https']2324from . import __version__2526defaults = dict()27
11 unmodified lines
39defaults['max_retries'] = 040defaults['danger_mode'] = False41defaults['safe_mode'] = False42defaults['keep_alive'] = True4344
modified:requests/models.py+3 added-2 removed
19 unmodified lines
20from .packages.urllib3.exceptions import SSLError as _SSLError21from .packages.urllib3.exceptions import HTTPError as _HTTPError22from .packages.urllib3 import connectionpool, poolmanager23from .packages.urllib3.filepost import encode_multipart_formdata24from .defaults import SCHEMAS25from .exceptions import (26 ConnectionError, HTTPError, RequestException, Timeout, TooManyRedirects,27 URLRequired, SSLError)28from .utils import (29 get_encoding_from_headers, stream_untransfer, guess_filename, requote_uri,29 dict_from_string, supported_schemes, stream_decode_response_unicode)30 dict_from_string, stream_decode_response_unicode)31from .compat import (32 urlparse, urlunparse, urljoin, urlsplit, urlencode, str, bytes,33 SimpleCookie, is_py2)34
276 unmodified lines
311312 if not scheme:313 raise ValueError("Invalid URL %r: No schema supplied" % url)314314 if not scheme in supported_schemes():315 if not scheme in SCHEMAS:316 raise ValueError("Invalid scheme %r" % scheme)317318 netloc = netloc.encode('idna').decode('utf-8')319
470 unmodified lines
modified:requests/utils.py+9 added-14 removed
9 unmodified lines
10"""1112import cgi13import codecs14import os14import random15import re16import zlib1718from .compat import parse_http_list as _parse_list_header20from .compat import quote, unquote, cookielib, SimpleCookie, is_py219from .compat import quote, cookielib, SimpleCookie, is_py220from .compat import basestring, bytes212223def dict_from_string(s):
3 unmodified lines
2728 c = SimpleCookie()29 c.load(s)3032 for k,v in list(c.items()):31 for k, v in list(c.items()):32 cookies.update({k: v.value})3334 return cookies353637def guess_filename(obj):38 """Tries to guess the filename of the given object."""39 name = getattr(obj, 'name', None)40 if name and name[0] != '<' and name[-1] != '>':41 return name424344# From mitsuhiko/werkzeug (used with permission).45def parse_list_header(value):46 """Parse lists as described by RFC 2068 Section 2.47
121 unmodified lines
169 if len(params):170171 collector.append('; '.join(_params))172172 if not len(headers) == i+1:173 if not len(headers) == i + 1:174 collector.append(', ')175175176 # Remove trailing separators.177 if collector[-1] in (', ', '; '):178 del collector[-1]179180 return ''.join(collector)181182183183def randombytes(n):184 """Return n random bytes."""185 if is_py2:186 L = [chr(random.randrange(0, 256)) for i in range(n)]
152 unmodified lines
339 return str(r.content, encoding, errors='replace')340 except TypeError:341 return r.content342343344def stream_decompress(iterator, mode='gzip'):345 """346 Stream decodes an iterator over compressed data347
24 unmodified lines
372 rv = buf + dec.flush()373 if rv:374 yield rv375376377def stream_untransfer(gen, resp):378 if 'gzip' in resp.headers.get('content-encoding', ''):379 gen = stream_decompress(gen, mode='gzip')380 elif 'deflate' in resp.headers.get('content-encoding', ''):
6 unmodified lines
387UNRESERVED_SET = frozenset(388 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"389 + "0123456789-._~")390391392def unquote_unreserved(uri):393 """Un-escape any percent-escape sequences in a URI that are unreserved394 characters.395 This leaves all reserved, illegal and non-ASCII bytes encoded.
10 unmodified lines
406 else:407 parts[i] = '%' + parts[i]408 return ''.join(parts)409410411def requote_uri(uri):412 """Re-quote the given URI.413414 This function passes the given URI through an unquote/quote cycle to
2 unmodified lines
417 # Unquote only the unreserved characters418 # Then quote only illegal characters (do not quote reserved, unreserved,419 # or '%')420 return quote(unquote_unreserved(uri), safe="!#$%&'()*+,/:;=?@[]~")418 return "/".join(parts)419420def supported_schemes():421 """A list of schemes supported by requests.422423 return: a list of strings.424 """425 return ["http","https"]