Merge branch 'master' of github.com:kennethreitz/requests
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 · parents 3857431, 4ad4670 · Browse files · 17 files·+49 added−75 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
17 files+49 added−75 removed
- tests:+5 added−5 removed
- other:+44 added−70 removed
Provenance
- Commit
916d171- Tree
fc8b674- Author
Kenneth Reitz <me@kennethreitz.org>- Committer
Kenneth Reitz <me@kennethreitz.org>- Parent 1
3857431- Parent 2
4ad4670
17 files changed+49 added−75 removed
modified:docs/_templates/sidebarintro.html+2 added-2 removed
56 unmodified lines5758596061616263636465666713 unmodified lines56 unmodified lines <li><a href="http://docs.python-requests.org/en/latest/community/recommended/">Recommended Packages and Extensions</a></li>
<p></p>
<li><a href="http://github.com/kennethreitz/requests">Requests @ GitHub</a></li> <li><a href="http://github.com/requests/requests">Requests @ GitHub</a></li> <li><a href="http://pypi.python.org/pypi/requests">Requests @ PyPI</a></li> <li><a href="http://github.com/kennethreitz/requests/issues">Issue Tracker</a></li> <li><a href="http://github.com/requests/requests/issues">Issue Tracker</a></li> <li><a href="http://docs.python-requests.org/en/latest/community/updates/#software-updates">Release History</a></li></ul>
13 unmodified linesmodified:docs/community/support.rst+1 added-1 removed
24 unmodified lines25 -------------26 27 If you notice some unexpected behaviour in Requests, or want to see support28 for a new feature,29-`file an issue on GitHub <https://github.com/kennethreitz/requests/issues>`_.29+`file an issue on GitHub <https://github.com/requests/requests/issues>`_.30 31 32 E-mail33 ------18 unmodified linesmodified:docs/community/updates.rst+1 added-1 removed
10 unmodified lines11 GitHub12 ------13 14 The best way to track the development of Requests is through15-`the GitHub repo <https://github.com/kennethreitz/requests>`_.15+`the GitHub repo <https://github.com/requests/requests>`_.16 17 Twitter18 -------19 11 unmodified linesmodified:docs/dev/contributing.rst+1 added-1 removed
185 unmodified lines186 through the `GitHub issues`_, **both open and closed**, to confirm that the bug187 hasn't been reported before. Duplicate bug reports are a huge drain on the time188 of other contributors, and should be avoided as much as possible.189 190-.. _GitHub issues: https://github.com/kennethreitz/requests/issues190+.. _GitHub issues: https://github.com/requests/requests/issues191 192 193 Feature Requests194 ----------------12 unmodified linesmodified:docs/dev/todo.rst+2 added-2 removed
4 unmodified lines5 6 #. Check for open issues or open a fresh issue to start a discussion around a bug.7 There is a Contributor Friendly tag for issues that should be ideal for people who are not very8 familiar with the codebase yet.9-#. Fork `the repository <https://github.com/kennethreitz/requests>`_ on GitHub and start making your9+#. Fork `the repository <https://github.com/requests/requests>`_ on GitHub and start making your10 changes to a new branch.11 #. Write a test which shows that the bug was fixed.12 #. Send a pull request and bug the maintainer until it gets merged and published. :)13- Make sure to add yourself to `AUTHORS <https://github.com/kennethreitz/requests/blob/master/AUTHORS.rst>`_.13+ Make sure to add yourself to `AUTHORS <https://github.com/requests/requests/blob/master/AUTHORS.rst>`_.14 15 Feature Freeze16 --------------17 54 unmodified linesmodified:docs/user/advanced.rst+6 added-6 removed
278 unmodified lines279 immediately. You can override this behaviour and defer downloading the response280 body until you access the :attr:`Response.content <requests.Response.content>`281 attribute with the ``stream`` parameter::282 283- tarball_url = 'https://github.com/kennethreitz/requests/tarball/master'283+ tarball_url = 'https://github.com/requests/requests/tarball/master'284 r = requests.get(tarball_url, stream=True)285 286 At this point only the response headers have been downloaded and the connection287 remains open, hence allowing us to make content retrieval conditional::353 unmodified lines641 from GitHub. Suppose we wanted commit ``a050faf`` on Requests. We would get it642 like so::643 644 >>> import requests645- >>> r = requests.get('https://api.github.com/repos/kennethreitz/requests/git/commits/a050faf084662f3a352dd1a941f2c7c9f886d4ad')645+ >>> r = requests.get('https://api.github.com/repos/requests/requests/git/commits/a050faf084662f3a352dd1a941f2c7c9f886d4ad')646 647 We should confirm that GitHub responded correctly. If it has, we want to work648 out what type of content it is. Do this like so::649 46 unmodified lines696 we should probably avoid making ham-handed POSTS to it. Instead, let's play697 with the Issues feature of GitHub.698 699 This documentation was added in response to700-`Issue #482 <https://github.com/kennethreitz/requests/issues/482>`_. Given that700+`Issue #482 <https://github.com/requests/requests/issues/482>`_. Given that701 this issue already exists, we will use it as an example. Let's start by getting it.702 703 ::704 705- >>> r = requests.get('https://api.github.com/repos/kennethreitz/requests/issues/482')705+ >>> r = requests.get('https://api.github.com/repos/requests/requests/issues/482')706 >>> r.status_code707 200708 709 >>> issue = json.loads(r.text)34 unmodified lines744 745 ::746 747 >>> body = json.dumps({u"body": u"Sounds great! I'll get right on it!"})748- >>> url = u"https://api.github.com/repos/kennethreitz/requests/issues/482/comments"748+ >>> url = u"https://api.github.com/repos/requests/requests/issues/482/comments"749 750 >>> r = requests.post(url=url, data=body)751 >>> r.status_code752 40425 unmodified lines778 >>> print(content[u"id"])779 5804413780 781 >>> body = json.dumps({u"body": u"Sounds great! I'll get right on it once I feed my cat."})782- >>> url = u"https://api.github.com/repos/kennethreitz/requests/issues/comments/5804413"782+ >>> url = u"https://api.github.com/repos/requests/requests/issues/comments/5804413"783 784 >>> r = requests.patch(url=url, data=body, auth=auth)785 >>> r.status_code786 200206 unmodified linesmodified:docs/user/install.rst+1 added-1 removed
20 unmodified lines21 Get the Source Code22 -------------------23 24 Requests is actively developed on GitHub, where the code is25-`always available <https://github.com/kennethreitz/requests>`_.25+`always available <https://github.com/requests/requests>`_.26 27 You can either clone the public repository::28 29 $ git clone git://github.com/requests/requests.git10 unmodified linesmodified:docs/index.rst+4 added-4 removed
15 unmodified lines16 17 .. image:: https://img.shields.io/pypi/pyversions/requests.svg18 :target: https://pypi.python.org/pypi/requests19 20-.. image:: https://travis-ci.org/kennethreitz/requests.svg?branch=master21- :target: https://travis-ci.org/kennethreitz/requests20+.. image:: https://travis-ci.org/requests/requests.svg?branch=master21+ :target: https://travis-ci.org/requests/requests22 23-.. image:: https://codecov.io/github/kennethreitz/requests/coverage.svg?branch=master24- :target: https://codecov.io/github/kennethreitz/requests23+.. image:: https://codecov.io/github/requests/requests/coverage.svg?branch=master24+ :target: https://codecov.io/github/requests/requests25 :alt: codecov.io26 27 .. image:: https://img.shields.io/badge/Say%20Thanks!-🦉-1EAEDB.svg28 :target: https://saythanks.io/to/kennethreitz146 unmodified linesmodified:requests/auth.py+1 added-1 removed
225 unmodified lines226 :rtype: requests.Response227 """228 229 # If response is not 4xx, do not auth230- # See https://github.com/kennethreitz/requests/issues/3772230+ # See https://github.com/requests/requests/issues/3772231 if not 400 <= r.status_code < 500:232 self._thread_local.num_401_calls = 1233 return r234 59 unmodified linesmodified:requests/models.py+2 added-2 removed
11 unmodified lines12 import sys13 14 # Import encoding now, to avoid implicit import later.15 # Implicit import within threads may cause LookupError when standard library is in a ZIP,16-# such as in Embedded Python. See https://github.com/kennethreitz/requests/issues/3578.16+# such as in Embedded Python. See https://github.com/requests/requests/issues/3578.17 import encodings.idna18 19 from urllib3.fields import RequestField20 from urllib3.filepost import encode_multipart_formdata326 unmodified lines347 #: Accept objects that have string representations.348 #: We're unable to blindly call unicode/str functions349 #: as this will include the bytestring indicator (b'')350 #: on python 3.x.351- #: https://github.com/kennethreitz/requests/pull/2238351+ #: https://github.com/requests/requests/pull/2238352 if isinstance(url, bytes):353 url = url.decode('utf8')354 else:355 url = unicode(url) if is_py2 else str(url)587 unmodified linesmodified:requests/sessions.py+2 added-28 removed
11 unmodified lines12 import time13 from collections import Mapping14 from datetime import timedelta15 16-from urllib3._collections import RecentlyUsedContainer17-16 from .auth import _basic_auth_str17 from .compat import cookielib, is_py3, OrderedDict, urljoin, urlparse18 from .cookies import (19 cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar, merge_cookies)16 unmodified lines36 37 # formerly defined here, reexposed here for backward compatibility38 from .models import REDIRECT_STATI39 42-REDIRECT_CACHE_SIZE = 100043-40 # Preferred clock, based on which one is more accurate on a given system.41 if platform.system() == 'Windows':42 try: # Python 3.3+43 preferred_clock = time.perf_counter109 unmodified lines153 else:154 url = requote_uri(url)155 156 prepared_request.url = to_native_string(url)161- # Cache the url, unless it redirects to itself.162- if resp.is_permanent_redirect and req.url != prepared_request.url:163- self.redirect_cache[req.url] = prepared_request.url157 158 self.rebuild_method(prepared_request, resp)159 167- # https://github.com/kennethreitz/requests/issues/1084160+ # https://github.com/requests/requests/issues/1084161 if resp.status_code not in (codes.temporary_redirect, codes.permanent_redirect):169- # https://github.com/kennethreitz/requests/issues/3490162+ # https://github.com/requests/requests/issues/3490163 purged_headers = ('Content-Length', 'Content-Type', 'Transfer-Encoding')164 for header in purged_headers:165 prepared_request.headers.pop(header, None)166 prepared_request.body = None218 unmodified lines385 self.adapters = OrderedDict()386 self.mount('https://', HTTPAdapter())387 self.mount('http://', HTTPAdapter())388 396- # Only store 1000 redirects to prevent using infinite memory397- self.redirect_cache = RecentlyUsedContainer(REDIRECT_CACHE_SIZE)398-389 def __enter__(self):390 return self391 392 def __exit__(self, *args):219 unmodified lines612 allow_redirects = kwargs.pop('allow_redirects', True)613 stream = kwargs.get('stream')614 hooks = request.hooks615 626- # Resolve URL in redirect cache, if available.627- if allow_redirects:628- checked_urls = set()629- while request.url in self.redirect_cache:630- checked_urls.add(request.url)631- new_url = self.redirect_cache.get(request.url)632- if new_url in checked_urls:633- break634- request.url = new_url635-616 # Get the appropriate adapter to use617 adapter = self.get_adapter(url=request.url)618 619 # Start time (approximately) of the request104 unmodified lines724 self.adapters[key] = self.adapters.pop(key)725 726 def __getstate__(self):727 state = dict((attr, getattr(self, attr, None)) for attr in self.__attrs__)748- state['redirect_cache'] = dict(self.redirect_cache)728 return state729 730 def __setstate__(self, state):752- redirect_cache = state.pop('redirect_cache', {})731 for attr, value in state.items():732 setattr(self, attr, value)733 756- self.redirect_cache = RecentlyUsedContainer(REDIRECT_CACHE_SIZE)757- for redirect, to in redirect_cache.items():758- self.redirect_cache[redirect] = to734 760-735 def session():736 """737 Returns a :class:`Session` for context-management.738 4 unmodified linesmodified:requests/utils.py+1 added-1 removed
169 unmodified lines170 loc = os.path.expanduser('~/{0}'.format(f))171 except KeyError:172 # os.path.expanduser can fail when $HOME is undefined and173 # getpwuid fails. See http://bugs.python.org/issue20164 &174- # https://github.com/kennethreitz/requests/issues/1846174+ # https://github.com/requests/requests/issues/1846175 return176 177 if os.path.exists(loc):178 netrc_path = loc725 unmodified linesmodified:tests/test_lowlevel.py+2 added-2 removed
26 unmodified lines27 def test_digestauth_401_count_reset_on_redirect():28 """Ensure we correctly reset num_401_calls after a successful digest auth,29 followed by a 302 redirect to another digest auth prompt.30 31- See https://github.com/kennethreitz/requests/issues/1979.31+ See https://github.com/requests/requests/issues/1979.32 """33 text_401 = (b'HTTP/1.1 401 UNAUTHORIZED\r\n'34 b'Content-Length: 0\r\n'35 b'WWW-Authenticate: Digest nonce="6bf5d6e4da1ce66918800195d6b9130d"'101 unmodified lines137 138 def test_digestauth_only_on_4xx():139 """Ensure we only send digestauth on 4xx challenges.140 141- See https://github.com/kennethreitz/requests/issues/3772.141+ See https://github.com/requests/requests/issues/3772.142 """143 text_200_chal = (b'HTTP/1.1 200 OK\r\n'144 b'Content-Length: 0\r\n'145 b'WWW-Authenticate: Digest nonce="6bf5d6e4da1ce66918800195d6b9130d"'92 unmodified linesmodified:tests/test_requests.py+2 added-2 removed
453 unmodified lines454 455 @pytest.mark.parametrize('key', ('User-agent', 'user-agent'))456 def test_user_agent_transfers(self, httpbin, key):457 458- heads = {key: 'Mozilla/5.0 (github.com/kennethreitz/requests)'}458+ heads = {key: 'Mozilla/5.0 (github.com/requests/requests)'}459 460 r = requests.get(httpbin('user-agent'), headers=heads)461 assert heads[key] in r.text462 1611 unmodified lines2074 except ConnectTimeout:2075 pass2076 2077 def test_encoded_methods(self, httpbin):2078- """See: https://github.com/kennethreitz/requests/issues/2316"""2078+ """See: https://github.com/requests/requests/issues/2316"""2079 r = requests.request(b'GET', httpbin('get'))2080 assert r.ok2081 2082 290 unmodified linesmodified:tests/test_utils.py+1 added-1 removed
365 unmodified lines366 'http://example.com/fiz?buz=%25ppicture',367 ),368 ))369 def test_requote_uri_with_unquoted_percents(uri, expected):370- """See: https://github.com/kennethreitz/requests/issues/2356"""370+ """See: https://github.com/requests/requests/issues/2356"""371 assert requote_uri(uri) == expected372 373 374 @pytest.mark.parametrize(280 unmodified linesmodified:HISTORY.rst+8 added-8 removed
598 unmodified lines599 **Bugfixes**600 601 - Unicode URL improvements for Python 2.602 - Re-order JSON param for backwards compat.603-- Automatically defrag authentication schemes from host/pass URIs. (`#2249 <https://github.com/kennethreitz/requests/issues/2249>`_)603+- Automatically defrag authentication schemes from host/pass URIs. (`#2249 <https://github.com/requests/requests/issues/2249>`_)604 605 606 2.4.2 (2014-10-05)607 ++++++++++++++++++608 609 **Improvements**610 611-- FINALLY! Add json parameter for uploads! (`#2258 <https://github.com/kennethreitz/requests/pull/2258>`_)612-- Support for bytestring URLs on Python 3.x (`#2238 <https://github.com/kennethreitz/requests/pull/2238>`_)611+- FINALLY! Add json parameter for uploads! (`#2258 <https://github.com/requests/requests/pull/2258>`_)612+- Support for bytestring URLs on Python 3.x (`#2238 <https://github.com/requests/requests/pull/2238>`_)613 614 **Bugfixes**615 616-- Avoid getting stuck in a loop (`#2244 <https://github.com/kennethreitz/requests/pull/2244>`_)617-- Multiple calls to iter* fail with unhelpful error. (`#2240 <https://github.com/kennethreitz/requests/issues/2240>`_, `#2241 <https://github.com/kennethreitz/requests/issues/2241>`_)616+- Avoid getting stuck in a loop (`#2244 <https://github.com/requests/requests/pull/2244>`_)617+- Multiple calls to iter* fail with unhelpful error. (`#2240 <https://github.com/requests/requests/issues/2240>`_, `#2241 <https://github.com/requests/requests/issues/2241>`_)618 619 **Documentation**620 621-- Correct redirection introduction (`#2245 <https://github.com/kennethreitz/requests/pull/2245/>`_)622-- Added example of how to send multiple files in one request. (`#2227 <https://github.com/kennethreitz/requests/pull/2227/>`_)623-- Clarify how to pass a custom set of CAs (`#2248 <https://github.com/kennethreitz/requests/pull/2248/>`_)621+- Correct redirection introduction (`#2245 <https://github.com/requests/requests/pull/2245/>`_)622+- Added example of how to send multiple files in one request. (`#2227 <https://github.com/requests/requests/pull/2227/>`_)623+- Clarify how to pass a custom set of CAs (`#2248 <https://github.com/requests/requests/pull/2248/>`_)624 625 626 627 2.4.1 (2014-09-09)819 unmodified linesmodified:README.rst+12 added-12 removed
8 unmodified lines9 10 .. image:: https://img.shields.io/pypi/pyversions/requests.svg11 :target: https://pypi.python.org/pypi/requests12 13-.. image:: https://travis-ci.org/kennethreitz/requests.svg?branch=master14- :target: https://travis-ci.org/kennethreitz/requests13+.. image:: https://travis-ci.org/requests/requests.svg?branch=master14+ :target: https://travis-ci.org/requests/requests15 16-.. image:: https://codecov.io/github/kennethreitz/requests/coverage.svg?branch=master17- :target: https://codecov.io/github/kennethreitz/requests16+.. image:: https://codecov.io/github/requests/requests/coverage.svg?branch=master17+ :target: https://codecov.io/github/requests/requests18 :alt: codecov.io19- 20-.. image:: https://img.shields.io/github/contributors/kennethreitz/requests.svg21- :target: https://github.com/kennethreitz/requests/graphs/contributors22- 19+20+.. image:: https://img.shields.io/github/contributors/requests/requests.svg21+ :target: https://github.com/requests/requests/graphs/contributors22+23 .. image:: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg24 :target: https://saythanks.io/to/kennethreitz25 26 22 unmodified lines49 {u'disk_usage': 368627, u'private_gists': 484, ...}50 51 See `the similar code, sans Requests <https://gist.github.com/973705>`_.52 53-.. image:: https://raw.githubusercontent.com/kennethreitz/requests/master/docs/_static/requests-logo-small.png53+.. image:: https://raw.githubusercontent.com/requests/requests/master/docs/_static/requests-logo-small.png54 :target: http://docs.python-requests.org/55 56 57 Requests allows you to send *organic, grass-fed* HTTP/1.1 requests, without the53 unmodified lines111 #. Fork `the repository`_ on GitHub to start making your changes to the **master** branch (or branch off of it).112 #. Write a test which shows that the bug was fixed or that the feature works as expected.113 #. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS_.114 115-.. _`the repository`: http://github.com/kennethreitz/requests116-.. _AUTHORS: https://github.com/kennethreitz/requests/blob/master/AUTHORS.rst117-.. _Contributor Friendly: https://github.com/kennethreitz/requests/issues?direction=desc&labels=Contributor+Friendly&page=1&sort=updated&state=open115+.. _`the repository`: http://github.com/requests/requests116+.. _AUTHORS: https://github.com/requests/requests/blob/master/AUTHORS.rst117+.. _Contributor Friendly: https://github.com/requests/requests/issues?direction=desc&labels=Contributor+Friendly&page=1&sort=updated&state=open