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
Provenance
- Commit
39ad5e7- Tree
19b5c1a- Author
s7v7nislands <s7v7nislands@gmail.com>- Committer
s7v7nislands <s7v7nislands@gmail.com>- Parent 1
0df505b- Parent 2
3229365
12 files changed+72 added−22 removed
modified:docs/user/quickstart.rst+3 added
69 unmodified lines70 71 >>> print r.url72 http://httpbin.org/get?key2=value2&key1=value173 74+Note that any dictionary key whose value is ``None`` will not be added to the75+URL's query string.76 77+78 Response Content79 ----------------80 81 We can read the content of the server's response. Consider the GitHub timeline335 unmodified linesmodified:requests/packages/urllib3/contrib/pyopenssl.py+3 added
104 unmodified lines105 def __init__(self, connection, socket):106 self.connection = connection107 self.socket = socket108 109+ def fileno(self):110+ return self.socket.fileno()111+112 def makefile(self, mode, bufsize=-1):113 return _fileobject(self.connection, mode, bufsize)114 115 def settimeout(self, timeout):58 unmodified linesmodified:requests/packages/urllib3/_collections.py+8 added-8 removed
3 unmodified lines4 # This module is part of urllib3 and is released under5 # the MIT License: http://www.opensource.org/licenses/mit-license.php6 7 from collections import MutableMapping8-from threading import Lock8+from threading import RLock9 10 try: # Python 2.7+11 from collections import OrderedDict12 except ImportError:26 unmodified lines39 self._maxsize = maxsize40 self.dispose_func = dispose_func41 42 self._container = self.ContainerCls()43- self._lock = Lock()43+ self.lock = RLock()44 45 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 item51 52 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 lines64 if self.dispose_func and evicted_value is not _Null:65 self.dispose_func(evicted_value)66 67 def __delitem__(self, key):68- with self._lock:68+ with self.lock:69 value = self._container.pop(key)70 71 if self.dispose_func:72 self.dispose_func(value)73 74 def __len__(self):75- with self._lock:75+ with self.lock:76 return len(self._container)77 78 def __iter__(self):79 raise NotImplementedError('Iteration over this class is unlikely to be threadsafe.')80 81 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 lines89 for value in values:90 self.dispose_func(value)91 92 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 lines103 port = port or port_by_scheme.get(scheme, 80)104 105 pool_key = (scheme, host, port)106 107+ 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 pool113 113- # 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 pool118 119 def connection_from_url(self, url):120 """82 unmodified linesmodified:requests/packages/urllib3/util.py+3 added-2 removed
111 unmodified lines112 """113 114 # 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.118 119 scheme = None120 auth = None20 unmodified lines141 auth, url = url.split('@', 1)142 143 # IPv6144 if url and url[0] == '[':145- host, url = url[1:].split(']', 1)145+ host, url = url.split(']', 1)146+ host += ']'147 148 # Port149 if ':' in url:150 _host, port = url.split(':', 1)242 unmodified linesmodified:requests/cookies.py+5 added
257 unmodified lines258 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)261 262+ 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)266+267 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 linesmodified:requests/models.py+1 added-1 removed
542 unmodified lines543 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 linesmodified:requests/sessions.py+2 added-2 removed
287 unmodified lines288 env_proxies = get_environ_proxies(url) or {}289 for (k, v) in env_proxies.items():290 proxies.setdefault(k, v)291 292- # 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)295 296 # Look for configuration.297 if not verify and verify is not False:207 unmodified linesmodified:requests/status_codes.py+2 added-1 removed
16 unmodified lines17 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',),23 24 # Redirection.25 300: ('multiple_choices',),26 301: ('moved_permanently', 'moved', '\\o-'),62 unmodified linesmodified:AUTHORS.rst+1 added
129 unmodified lines130 - Łukasz Langa <lukasz@langa.pl> @llanga131 - Dave Shawley <daveshawley@gmail.com>132 - James Clarke (jam)133 - Kevin Burke <kev@inburke.com>134+- Flavio Curellamodified:README.rst+2 added
1 Requests: HTTP for Humans2 =========================3 4+.. image:: https://badge.fury.io/py/requests.png5+ :target: http://badge.fury.io/py/requests6 7 .. image:: https://travis-ci.org/kennethreitz/requests.png?branch=master8 :target: https://travis-ci.org/kennethreitz/requests9 83 unmodified linesmodified:test_requests.py+33 added
168 unmodified lines169 }170 )171 assert 'foo' not in s.cookies172 173+ 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"')177+178 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 lines238 s.auth = auth239 r = s.get(url)240 self.assertEqual(r.status_code, 200)241 242+ def test_basicauth_with_netrc(self):243+ auth = ('user', 'pass')244+ wrong_auth = ('wronguser', 'wrongpass')245+ url = httpbin('basic-auth', 'user', 'pass')246+247+ def get_netrc_auth_mock(url):248+ return auth249+ requests.sessions.get_netrc_auth = get_netrc_auth_mock250+251+ # Should use netrc and work.252+ r = requests.get(url)253+ self.assertEqual(r.status_code, 200)254+255+ # Given auth should override and fail.256+ r = requests.get(url, auth=wrong_auth)257+ self.assertEqual(r.status_code, 401)258+259+ s = requests.session()260+ 261+ # Should use netrc and work.262+ r = s.get(url)263+ self.assertEqual(r.status_code, 200)264+265+ # Given auth should override and fail.266+ s.auth = wrong_auth267+ r = s.get(url)268+ self.assertEqual(r.status_code, 401)269+270 def test_DIGEST_HTTP_200_OK_GET(self):271 272 auth = HTTPDigestAuth('user', 'pass')273 url = httpbin('digest-auth', 'auth', 'user', 'pass')508 unmodified lines