Skip to content
Myr

merge

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

authored by s7v7nislands · committed by s7v7nislands · parents 0df505b, 3229365 · Browse files · 12 files+72 added−22 removed
This commit

State

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

Diff stats

12 files+72 added−22 removed

  • other:+72 added−22 removed

12 files+72 added−22 removed

modified:docs/user/quickstart.rst+3 added
69 unmodified lines
7071 >>> print r.url72 http://httpbin.org/get?key2=value2&key1=value17374Note that any dictionary key whose value is ``None`` will not be added to the75URL's query string.767778Response Content79----------------8081We can read the content of the server's response. Consider the GitHub timeline
335 unmodified lines
modified:requests/packages/urllib3/contrib/pyopenssl.py+3 added
104 unmodified lines
105 def __init__(self, connection, socket):106 self.connection = connection107 self.socket = socket108109 def fileno(self):110 return self.socket.fileno()111112 def makefile(self, mode, bufsize=-1):113 return _fileobject(self.connection, mode, bufsize)114115 def settimeout(self, timeout):
58 unmodified lines
modified:requests/packages/urllib3/_collections.py+8 added-8 removed
3 unmodified lines
4# This module is part of urllib3 and is released under5# the MIT License: http://www.opensource.org/licenses/mit-license.php67from collections import MutableMapping8from threading import Lock8from threading import RLock910try: # Python 2.7+11 from collections import OrderedDict12except ImportError:
26 unmodified lines
39 self._maxsize = maxsize40 self.dispose_func = dispose_func4142 self._container = self.ContainerCls()43 self._lock = Lock()43 self.lock = RLock()4445 def __getitem__(self, key):46 # Re-insert the item, moving it to the end of the eviction line.47 with self._lock:47 with self.lock:48 item = self._container.pop(key)49 self._container[key] = item50 return item5152 def __setitem__(self, key, value):53 evicted_value = _Null54 with self._lock:54 with self.lock:55 # Possibly evict the existing value of 'key'56 evicted_value = self._container.get(key, _Null)57 self._container[key] = value58
5 unmodified lines
64 if self.dispose_func and evicted_value is not _Null:65 self.dispose_func(evicted_value)6667 def __delitem__(self, key):68 with self._lock:68 with self.lock:69 value = self._container.pop(key)7071 if self.dispose_func:72 self.dispose_func(value)7374 def __len__(self):75 with self._lock:75 with self.lock:76 return len(self._container)7778 def __iter__(self):79 raise NotImplementedError('Iteration over this class is unlikely to be threadsafe.')8081 def clear(self):82 with self._lock:82 with self.lock:83 # Copy pointers to all values, then wipe the mapping84 # under Python 2, this copies the list of values twice :-|85 values = list(self._container.values())86 self._container.clear()
2 unmodified lines
89 for value in values:90 self.dispose_func(value)9192 def keys(self):93 with self._lock:93 with self.lock:94 return self._container.keys()
modified:requests/packages/urllib3/poolmanager.py+9 added-8 removed
102 unmodified lines
103 port = port or port_by_scheme.get(scheme, 80)104105 pool_key = (scheme, host, port)106107 with self.pools.lock:107 # If the scheme, host, or port doesn't match existing open connections,108 # open a new ConnectionPool.109 pool = self.pools.get(pool_key)110 if pool:111 return pool108 # If the scheme, host, or port doesn't match existing open connections,109 # open a new ConnectionPool.110 pool = self.pools.get(pool_key)111 if pool:112 return pool113113 # Make a fresh ConnectionPool of the desired type114 pool = self._new_pool(scheme, host, port)115 self.pools[pool_key] = pool114 # Make a fresh ConnectionPool of the desired type115 pool = self._new_pool(scheme, host, port)116 self.pools[pool_key] = pool117 return pool118119 def connection_from_url(self, url):120 """
82 unmodified lines
modified:requests/packages/urllib3/util.py+3 added-2 removed
111 unmodified lines
112 """113114 # While this code has overlap with stdlib's urlparse, it is much115 # simplified for our needs and less annoying.116 # Additionally, this imeplementations does silly things to be optimal116 # Additionally, this implementations does silly things to be optimal117 # on CPython.118119 scheme = None120 auth = None
20 unmodified lines
141 auth, url = url.split('@', 1)142143 # IPv6144 if url and url[0] == '[':145 host, url = url[1:].split(']', 1)145 host, url = url.split(']', 1)146 host += ']'147148 # Port149 if ':' in url:150 _host, port = url.split(':', 1)
242 unmodified lines
modified:requests/cookies.py+5 added
257 unmodified lines
258 def __delitem__(self, name):259 """Deletes a cookie given a name. Wraps cookielib.CookieJar's remove_cookie_by_name()."""260 remove_cookie_by_name(self, name)261262 def set_cookie(self, cookie, *args, **kwargs):263 if cookie.value.startswith('"') and cookie.value.endswith('"'):264 cookie.value = cookie.value.replace('\\"', '')265 return super(RequestsCookieJar, self).set_cookie(cookie, *args, **kwargs)266267 def update(self, other):268 """Updates this jar with cookies from another CookieJar or dict-like"""269 if isinstance(other, cookielib.CookieJar):270 for cookie in other:
129 unmodified lines
modified:requests/models.py+1 added-1 removed
542 unmodified lines
543 yield chunk544 except AttributeError:545 # Standard file-like object.546 while 1:547 chunk = self.raw.read(chunk_size, decode_content=True)547 chunk = self.raw.read(chunk_size)548 if not chunk:549 break550 yield chunk551
142 unmodified lines
modified:requests/sessions.py+2 added-2 removed
287 unmodified lines
288 env_proxies = get_environ_proxies(url) or {}289 for (k, v) in env_proxies.items():290 proxies.setdefault(k, v)291292 # Set environment's basic authentication.293 if not auth:292 # Set environment's basic authentication if not explicitly set.293 if not auth and not self.auth:294 auth = get_netrc_auth(url)295296 # Look for configuration.297 if not verify and verify is not False:
207 unmodified lines
modified:requests/status_codes.py+2 added-1 removed
16 unmodified lines
17 204: ('no_content',),18 205: ('reset_content', 'reset'),19 206: ('partial_content', 'partial'),20 207: ('multi_status', 'multiple_status', 'multi_stati', 'multiple_stati'),21 208: ('im_used',),21 208: ('already_reported',),22 226: ('im_used',),2324 # Redirection.25 300: ('multiple_choices',),26 301: ('moved_permanently', 'moved', '\\o-'),
62 unmodified lines
modified:AUTHORS.rst+1 added
129 unmodified lines
130- Łukasz Langa <lukasz@langa.pl> @llanga131- Dave Shawley <daveshawley@gmail.com>132- James Clarke (jam)133- Kevin Burke <kev@inburke.com>134- Flavio Curella
modified:README.rst+2 added
1Requests: HTTP for Humans2=========================34.. image:: https://badge.fury.io/py/requests.png5 :target: http://badge.fury.io/py/requests67.. image:: https://travis-ci.org/kennethreitz/requests.png?branch=master8 :target: https://travis-ci.org/kennethreitz/requests9
83 unmodified lines
modified:test_requests.py+33 added
168 unmodified lines
169 }170 )171 assert 'foo' not in s.cookies172173 def test_cookie_quote_wrapped(self):174 s = requests.session()175 s.get(httpbin('cookies/set?foo="bar:baz"'))176 self.assertTrue(s.cookies['foo'] == '"bar:baz"')177178 def test_request_cookie_overrides_session_cookie(self):179 s = requests.session()180 s.cookies['foo'] = 'bar'181 r = s.get(httpbin('cookies'), cookies={'foo': 'baz'})
56 unmodified lines
238 s.auth = auth239 r = s.get(url)240 self.assertEqual(r.status_code, 200)241242 def test_basicauth_with_netrc(self):243 auth = ('user', 'pass')244 wrong_auth = ('wronguser', 'wrongpass')245 url = httpbin('basic-auth', 'user', 'pass')246247 def get_netrc_auth_mock(url):248 return auth249 requests.sessions.get_netrc_auth = get_netrc_auth_mock250251 # Should use netrc and work.252 r = requests.get(url)253 self.assertEqual(r.status_code, 200)254255 # Given auth should override and fail.256 r = requests.get(url, auth=wrong_auth)257 self.assertEqual(r.status_code, 401)258259 s = requests.session()260 261 # Should use netrc and work.262 r = s.get(url)263 self.assertEqual(r.status_code, 200)264265 # Given auth should override and fail.266 s.auth = wrong_auth267 r = s.get(url)268 self.assertEqual(r.status_code, 401)269270 def test_DIGEST_HTTP_200_OK_GET(self):271272 auth = HTTPDigestAuth('user', 'pass')273 url = httpbin('digest-auth', 'auth', 'user', 'pass')
508 unmodified lines