Skip to content
Myr

Merge pull request #1 from requests/master

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

Syncing fork to the original repository

authored by Maina Nick · committed by GitHub · parents f78a579, 7c812e9 · Browse files · 66 files+4000 added−2163 removed
This commit

State

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

Diff stats

66 files+4000 added−2163 removed

  • tests:+382 added−96 removed
  • other:+3618 added−2067 removed

66 files+4000 added−2163 removed

modified:_appveyor/install.ps1+1 added-1 removed
224 unmodified lines
225 InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON226 InstallPip $env:PYTHON227}228229main229main
added:.github/ISSUE_TEMPLATE/Bug_report.md+34 added
added:.github/ISSUE_TEMPLATE/Custom.md+7 added
added:.github/ISSUE_TEMPLATE/Feature_request.md+7 added
modified:docs/_static/custom.css+146 added-3 removed
added:docs/_static/native.js+131 added
1var _native = (function () {2 var _options = {}3 var _construct = function (e) {4 var defaultOptions = {5 carbonZoneKey: '',6 fallback: '',7 ignore: 'false',8 placement: '',9 prefix: 'native',10 targetClass: 'native-ad'11 }1213 if (typeof e === 'undefined') return defaultOptions14 Object.keys(defaultOptions).forEach((key, index) => {15 if (typeof e[key] === 'undefined') {16 e[key] = defaultOptions[key]17 }18 })19 return e20 }2122 var init = function (zone, options) {23 _options = _construct(options)2425 let jsonUrl = `https://srv.buysellads.com/ads/${zone}.json?callback=_native_go`26 if (_options['placement'] !== '') {27 jsonUrl += '&segment=placement:' + _options['placement']28 }29 if (_options['ignore'] === 'true') {30 jsonUrl += '&ignore=yes'31 }3233 let srv = document.createElement('script')34 srv.src = jsonUrl35 document.getElementsByTagName('head')[0].appendChild(srv)36 }3738 var carbon = function (e) {39 let srv = document.createElement('script')40 srv.src = '//cdn.carbonads.com/carbon.js?serve=' + e['carbonZoneKey'] + '&placement=' + e['placement']41 srv.id = '_carbonads_js'4243 return srv44 }4546 var sanitize = function (ads) {47 return ads48 .filter(ad => {49 return Object.keys(ad).length > 050 })51 .filter(ad => {52 return ad.hasOwnProperty('statlink')53 })54 }5556 var pixel = function (p, timestamp) {57 let c = ''58 if (p) {59 p.split('||').forEach((pixel, index) => {60 c += `<img src="${pixel.replace('[timestamp]', timestamp)}" style="display:none;" height="0" width="0" />`61 })62 }63 return c64 }6566 var options = function () {67 return _options68 }6970 return {71 carbon: carbon,72 init: init,73 options: options,74 pixel: pixel,75 sanitize: sanitize76 }77})({})7879var _native_go = function (json) {80 let options = _native.options()81 let ads = _native.sanitize(json['ads'])82 let selectedClass = document.querySelectorAll('.' + options['targetClass'])8384 if (ads.length < 1) {85 selectedClass.forEach((className, index) => {86 let selectedTarget = document.getElementsByClassName(options['targetClass'])[index]8788 if (options['fallback'] !== '' || options['carbonZoneKey'] !== '') selectedTarget.setAttribute('data-state', 'visible')89 selectedTarget.innerHTML = options['fallback']90 if (options['carbonZoneKey'] !== '') selectedTarget.appendChild(_native.carbon(options))91 })9293 // End at this line if no ads are found, avoiding unnecessary steps94 return95 }9697 selectedClass.forEach((className, index) => {98 let selectedTarget = document.getElementsByClassName(options['targetClass'])[index]99 let adElement = selectedTarget.innerHTML100 let prefix = options['prefix']101 let ad = ads[index]102103 if (ad && className) {104 let adInnerHtml = adElement105 .replace(new RegExp('#' + prefix + '_bg_color#', 'g'), ad['backgroundColor'])106 .replace(new RegExp('#' + prefix + '_bg_color_hover#', 'g'), ad['backgroundHoverColor'])107 .replace(new RegExp('#' + prefix + '_company#', 'g'), ad['company'])108 .replace(new RegExp('#' + prefix + '_cta#', 'g'), ad['callToAction'])109 .replace(new RegExp('#' + prefix + '_cta_bg_color#', 'g'), ad['ctaBackgroundColor'])110 .replace(new RegExp('#' + prefix + '_cta_bg_color_hover#', 'g'), ad['ctaBackgroundHoverColor'])111 .replace(new RegExp('#' + prefix + '_cta_color#', 'g'), ad['ctaTextColor'])112 .replace(new RegExp('#' + prefix + '_cta_color_hover#', 'g'), ad['ctaTextColorHover'])113 .replace(new RegExp('#' + prefix + '_desc#', 'g'), ad['description'])114 .replace(new RegExp('#' + prefix + '_index#', 'g'), prefix + '-' + ad['i'])115 .replace(new RegExp('#' + prefix + '_img#', 'g'), ad['image'])116 .replace(new RegExp('#' + prefix + '_small_img#', 'g'), ad['smallImage'])117 .replace(new RegExp('#' + prefix + '_link#', 'g'), ad['statlink'])118 .replace(new RegExp('#' + prefix + '_logo#', 'g'), ad['logo'])119 .replace(new RegExp('#' + prefix + '_color#', 'g'), ad['textColor'])120 .replace(new RegExp('#' + prefix + '_color_hover#', 'g'), ad['textColorHover'])121 .replace(new RegExp('#' + prefix + '_title#', 'g'), ad['title'])122123 selectedTarget.innerHTML = null124 selectedTarget.innerHTML += adInnerHtml + _native.pixel(ad['pixel'], ad['timestamp'])125 selectedTarget.setAttribute('data-state', 'visible')126 } else {127 selectedTarget.innerHTML = null128 selectedTarget.style.display = 'none'129 }130 })131}
modified:docs/_templates/hacks.html+50 added-1 removed
24 unmodified lines
25 }2627</style>282930<!-- Analytics tracking for Kenneth. -->31<script type="text/javascript">32 var _gauges = _gauges || [];33 (function() {
8 unmodified lines
42 s.parentNode.insertBefore(t, s);43 })();44</script>454647<!-- There are no more hacks. -->48<!-- இڿڰۣ-ڰۣ— -->49<!-- Love, Kenneth Reitz -->50
1 unmodified line
52<script>53 var easter_egg = new Konami('http://fortunes.herokuapp.com/random/raw');54</script>5554<!-- That was not a hack. That was art. -->56<!-- That was not a hack. That was art. -->5758<!-- Native CPC by BuySellAds -->5960<script src="{{ pathto('_static/', 1) }}/native.js"></script>61<script>62 _native.init("CK7D62JU", {63 targetClass: 'native-js'64 });65</script>6667<div class="native-js">68 <div class="native-sponsor">Sponsored Ad by #native_company# — Learn More</div>69 <a href="#native_link#" class="native-flex">70 <style>71 .native-js {72 background: linear-gradient(-30deg, #native_bg_color#E5, #native_bg_color#E5 45%, #native_bg_color# 45%) #fff;73 }7475 .native-details,76 .native-sponsor {77 color: #native_color# !important;78 }7980 .native-details:hover {81 color: #native_color_hover# !important;82 }8384 .native-cta {85 color: #native_cta_color#;86 background-color: #native_cta_bg_color#;87 }8889 .native-cta:hover {90 color: #native_cta_color_hover;91 background-color: #native_cta_bg_color_hover#;92 }93 </style>94 <div class="native-main">95 <img class="native-img" src="#native_logo#">96 <div class="native-details">97 <span class="native-company">#native_title#</span>98 <span class="native-desc">#native_desc#</span>99 </div>100 <span class="native-cta">#native_cta#</span>101 </div>102 </a>103</div>
modified:docs/_templates/sidebarintro.html+53 added-15 removed
3 unmodified lines
4 </a>5</p>67<p>8 <iframe src="http://ghbtns.com/github-btn.html?user=requests&repo=requests&type=watch&count=true&size=large"8 <iframe src="https://ghbtns.com/github-btn.html?user=requests&repo=requests&type=watch&count=true&size=large"9 allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px"></iframe>10</p>1112<p>13 Requests is an elegant and simple HTTP library for Python, built for14 human beings.15</p>16<p>Sponsored by <strong><a href="https://linode.com/">Linode</a></strong> and <a href="http://docs.python-requests.org/en/master/community/sponsors/#patron-sponsors">other wonderful organizations</a>.</p>1717<script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=pythonrequestsorg" id="_carbonads_js"></script>1819<script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=CKYI5K3E&placement=pythonrequestsorg" id="_carbonads_js"></script>2021<h3>Stay Informed</h3>22<p>Receive updates on new releases and upcoming projects.</p>2322<p><iframe src="http://ghbtns.com/github-btn.html?user=kennethreitz&type=follow&count=false"24<p><iframe src="https://ghbtns.com/github-btn.html?user=kennethreitz&type=follow&count=false"25 allowtransparency="true" frameborder="0" scrolling="0" width="200" height="20"></iframe></p>2627<p><a href="https://twitter.com/kennethreitz" class="twitter-follow-button" data-show-count="false">Follow @kennethreitz</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script></p>26<p><a href="https://saythanks.io/to/kennethreitz">Say Thanks!</a></p>27<p><a href="http://tinyletter.com/kennethreitz">Join Mailing List</a>.</p>28<p><a href="https://tinyletter.com/kennethreitz">Join Mailing List</a>.</p>282929<h3>Other Projects</h3>3032<p>More <a href="http://kennethreitz.org/">Kenneth Reitz</a> projects:</p>31<p>More <a href="https://www.kennethreitz.org/">Kenneth Reitz</a> projects:</p>32<ul>34 <li><a href="http://edmsynths.com/">edmsynths.com</a></li>33 <li><a href="https://html.python-requests.org/">Requests-HTML</a></li>34 <li><a href="http://howtopython.org/">howtopython.org</a></li>35 <li><a href="http://pipenv.org/">pipenv</a></li>36 <li><a href="http://pep8.org/">pep8.org</a></li>37 <li><a href="http://httpbin.org/">httpbin.org</a></li>38 <li><a href="http://python-guide.org">The Python Guide</a></li>36 <li><a href="https://pep8.org/">pep8.org</a></li>37 <li><a href="https://httpbin.org/">httpbin.org</a></li>38 <li><a href="https://docs.python-guide.org/">The Python Guide</a></li>39 <li><a href="https://github.com/kennethreitz/maya">Maya: Datetimes for Humans</a></li>40 <li><a href="https://github.com/kennethreitz/records">Records: SQL for Humans</a></li>41 <li><a href="http://www.git-legit.org">Legit: Git for Humans</a></li>42 <li><a href="http://docs.python-tablib.org/en/latest/">Tablib: Tabular Datasets</a></li>
5 unmodified lines
48 <li><a href="http://docs.python-requests.org/en/latest/community/recommended/">Recommended Packages and Extensions</a></li>4950 <p></p>5152 <li><a href="http://github.com/requests/requests">Requests @ GitHub</a></li>53 <li><a href="http://pypi.python.org/pypi/requests">Requests @ PyPI</a></li>54 <li><a href="http://github.com/requests/requests/issues">Issue Tracker</a></li>52 <li><a href="https://github.com/requests/requests">Requests @ GitHub</a></li>53 <li><a href="https://pypi.org/project/requests/">Requests @ PyPI</a></li>54 <li><a href="https://github.com/requests/requests/issues">Issue Tracker</a></li>55 <li><a href="http://docs.python-requests.org/en/latest/community/updates/#software-updates">Release History</a></li>56</ul>5758
9 unmodified lines
68 <li><a href="http://it.python-requests.org/">Italian</a></li>69 <li><a href="http://es.python-requests.org/">Spanish</a></li>70</ul>7172<div class="native-js">73 <div class="native-sponsor">Sponsored by #native_company# — Learn More</div>74 <a href="#native_link#" class="native-flex">75 <style>76 .native-js {77 background: linear-gradient(-30deg, #native_bg_color#E5, #native_bg_color#E5 45%, #native_bg_color# 45%) #fff;78 }7980 .native-details,81 .native-sponsor,82 .native-bsa {83 color: #native_color# !important;84 }8586 .native-details:hover {87 color: #native_color_hover# !important;88 }8990 .native-cta {91 color: #native_cta_color#;92 background-color: #native_cta_bg_color#;93 }9495 .native-cta:hover {96 color: #native_cta_color_hover;97 background-color: #native_cta_bg_color_hover#;98 }99 </style>100 <div class="native-main">101 <img class="native-img" src="#native_logo#">102 <div class="native-details">103 <span class="native-company">#native_title#</span>104 <span class="native-desc">#native_desc#</span>105 </div>106 </div>107 <span class="native-cta">#native_cta#</span>108 </a>109</div>
modified:docs/_templates/sidebarlogo.html+12 added-11 removed
2 unmodified lines
3 <img class="logo" src="{{ pathto('_static/requests-sidebar.png', 1) }}" title="https://kennethreitz.org/tattoos"/>4 </a>5</p>6<p>7<iframe src="http://ghbtns.com/github-btn.html?user=requests&repo=requests&type=watch&count=true&size=large"7<iframe src="https://ghbtns.com/github-btn.html?user=requests&repo=requests&type=watch&count=true&size=large"8 allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px"></iframe>9</p>101112<p>13 Requests is an elegant and simple HTTP library for Python, built for14 human beings. You are currently looking at the documentation of the15 development release.16</p>1718<p>Sponsored by <strong><a href="https://linode.com/">Linode</a></strong> and <a href="http://docs.python-requests.org/en/master/community/sponsors/#patron-sponsors">other wonderful organizations</a>.</p>1920<h3>Stay Informed</h3>21<p>Receive updates on new releases and upcoming projects.</p>2220<p><a href="http://tinyletter.com/kennethreitz">Join Mailing List</a>.</p>23<p><a href="https://tinyletter.com/kennethreitz">Join Mailing List</a>.</p>2425<hr/>2627<script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=pythonrequestsorg" id="_carbonads_js"></script>2826<p>If you enjoy using this project, <a href="https://saythanks.io/to/kennethreitz">Say Thanks!</a></p>2728<p><iframe src="http://ghbtns.com/github-btn.html?user=kennethreitz&type=follow&count=false"29<p><iframe src="https://ghbtns.com/github-btn.html?user=kennethreitz&type=follow&count=false"30 allowtransparency="true" frameborder="0" scrolling="0" width="200" height="20"></iframe></p>3132<p><a href="https://twitter.com/kennethreitz" class="twitter-follow-button" data-show-count="false">Follow @kennethreitz</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script></p>333435<h3>Other Projects</h3>3636<p>More <a href="http://kennethreitz.org/">Kenneth Reitz</a> projects:</p>37<p>More <a href="https://www.kennethreitz.org/">Kenneth Reitz</a> projects:</p>38<ul>38 <li><a href="http://edmsynths.com/">edmsynths.com</a></li>39 <li><a href="https://html.python-requests.org/">Requests-HTML</a></li>40 <li><a href="http://howtopython.org/">howtopython.org</a></li>41 <li><a href="http://pipenv.org/">pipenv</a></li>40 <li><a href="http://pep8.org/">pep8.org</a></li>41 <li><a href="http://httpbin.org/">httpbin.org</a></li>42 <li><a href="http://python-guide.org">The Python Guide</a></li>42 <li><a href="https://pep8.org/">pep8.org</a></li>43 <li><a href="https://httpbin.org/">httpbin.org</a></li>44 <li><a href="https://docs.python-guide.org/">The Python Guide</a></li>45 <li><a href="https://github.com/kennethreitz/maya">Maya: Datetimes for Humans</a></li>46 <li><a href="https://github.com/kennethreitz/records">Records: SQL for Humans</a></li>47 <li><a href="http://www.git-legit.org">Legit: Git for Humans</a></li>48 <li><a href="http://docs.python-tablib.org/en/latest/">Tablib: Tabular Datasets</a></li>
11 unmodified lines
60 <li><a href="http://pt.python-requests.org/">Portuguese</a></li>61 <li><a href="http://it.python-requests.org/">Italian</a></li>62 <li><a href="http://es.python-requests.org/">Spanish</a></li>63</ul>62
modified:docs/community/faq.rst+4 added-3 removed
1 unmodified line
23Frequently Asked Questions4==========================56.. image:: https://farm5.staticflickr.com/4290/35294660055_42c02b2316_k_d.jpg78This part of the documentation answers common questions about Requests.910Encoded Data?11-------------
43 unmodified lines
5556Yes! Here's a list of Python platforms that are officially57supported:5857* Python 2.659* Python 2.759* Python 3.360* Python 3.461* Python 3.562* Python 3.663* Python 3.764* PyPy6566What are "hostname doesn't match" errors?67-----------------------------------------
1 unmodified line
69These errors occur when :ref:`SSL certificate verification <verification>`70fails to match the certificate the server responds with to the hostname71Requests thinks it's contacting. If you're certain the server's SSL setup is72correct (for example, because you can visit the site with your browser) and72you're using Python 2.6 or 2.7, a possible explanation is that you need73you're using Python 2.7, a possible explanation is that you need74Server-Name-Indication.7576`Server-Name-Indication`_, or SNI, is an official extension to SSL where the77client tells the server what hostname it is contacting. This is important
11 unmodified lines
modified:docs/community/out-there.rst+8 added-6 removed
1Integrations2============34.. image:: https://farm5.staticflickr.com/4239/34450900674_15863ddea0_k_d.jpg56Python for iOS7--------------89Requests is built into the wonderful `Python for iOS <https://itunes.apple.com/us/app/python-2.7-for-ios/id485729872?mt=Python8>`_ runtime!
4 unmodified lines
141516Articles & Talks17================16- `Python for the Web <http://gun.io/blog/python-for-the-web/>`_ teaches how to use Python to interact with the web, using Requests.17- `Daniel Greenfeld's Review of Requests <http://pydanny.blogspot.com/2011/05/python-http-requests-for-humans.html>`_18- `My 'Python for Humans' talk <http://python-for-humans.heroku.com>`_ ( `audio <http://codeconf.s3.amazonaws.com/2011/pycodeconf/talks/PyCodeConf2011%20-%20Kenneth%20Reitz.m4a>`_ )19- `Issac Kelly's 'Consuming Web APIs' talk <http://issackelly.github.com/Consuming-Web-APIs-with-Python-Talk/slides/slides.html>`_20- `Blog post about Requests via Yum <http://arunsag.wordpress.com/2011/08/17/new-package-python-requests-http-for-humans/>`_21- `Russian blog post introducing Requests <http://habrahabr.ru/blogs/python/126262/>`_18- `Python for the Web <https://www.gun.io/blog/python-for-the-web>`_ teaches how to use Python to interact with the web, using Requests.19- `Daniel Greenfeld's Review of Requests <https://pydanny.blogspot.com/2011/05/python-http-requests-for-humans.html>`_20- `My 'Python for Humans' talk <http://python-for-humans.heroku.com>`_ ( `audio <https://codeconf.s3.amazonaws.com/2011/pycodeconf/talks/PyCodeConf2011%20-%20Kenneth%20Reitz.m4a>`_ )21- `Issac Kelly's 'Consuming Web APIs' talk <https://issackelly.github.com/Consuming-Web-APIs-with-Python-Talk/slides/slides.html>`_22- `Blog post about Requests via Yum <https://arunsag.wordpress.com/2011/08/17/new-package-python-requests-http-for-humans/>`_23- `Russian blog post introducing Requests <https://habr.com/post/126262/>`_24- `Sending JSON in Requests <http://www.coglib.com/~icordasc/blog/2014/11/sending-json-in-requests.html>`_
modified:docs/community/recommended.rst+12 added-5 removed
1 unmodified line
23Recommended Packages and Extensions4===================================56.. image:: https://farm5.staticflickr.com/4218/35224319272_cfc0e621fb_k_d.jpg78Requests has a great variety of powerful and useful third-party extensions.9This page provides an overview of some of the best of them.1011Certifi CA Bundle
2 unmodified lines
14`Certifi`_ is a carefully curated collection of Root Certificates for15validating the trustworthiness of SSL certificates while verifying the16identity of TLS hosts. It has been extracted from the Requests project.1716.. _Certifi: http://certifi.io/en/latest/18.. _Certifi: https://github.com/certifi/python-certifi1920CacheControl21------------22
10 unmodified lines
33but do not belong in Requests proper. This library is actively maintained34by members of the Requests core team, and reflects the functionality most35requested by users within the community.3635.. _Requests-Toolbelt: http://toolbelt.readthedocs.io/en/latest/index.html37.. _Requests-Toolbelt: https://toolbelt.readthedocs.io/en/latest/index.html383940Requests-Threads41----------------4243`Requests-Threads` is a Requests session that returns the amazing Twisted's awaitable Deferreds instead of Response objects. This allows the use of ``async``/``await`` keyword usage on Python 3, or Twisted's style of programming, if desired.4445.. _Requests-Threads: https://github.com/requests/requests-threads4647Requests-OAuthlib48-----------------4950`requests-oauthlib`_ makes it possible to do the OAuth dance from Requests
10 unmodified lines
61`Betamax`_ records your HTTP interactions so the NSA does not have to.62A VCR imitation designed only for Python-Requests.6364.. _betamax: https://github.com/sigmavirus24/betamax555657
modified:docs/community/release-process.rst+10 added-9 removed
1Release Process and Rules2=========================34.. image:: https://farm5.staticflickr.com/4215/34450901614_b74ae720db_k_d.jpg56.. versionadded:: v2.6.278Starting with the version to be released after ``v2.6.2``, the following rules9will govern and describe how the Requests core team produces a new release.
8 unmodified lines
18Breaking changes are changes that break backwards compatibility with prior19versions. If the project were to change the ``text`` attribute on a20``Response`` object to a method, that would only happen in a Major release.2120Major releases may also include miscellaneous bug fixes and upgrades to21vendored packages. The core developers of Requests are committed to providing22a good user experience. This means we're also committed to preserving23backwards compatibility as much as possible. Major releases will be infrequent24and will need strong justifications before they are considered.22Major releases may also include miscellaneous bug fixes. The core developers of23Requests are committed to providing a good user experience. This means we're24also committed to preserving backwards compatibility as much as possible. Major25releases will be infrequent and will need strong justifications before they are26considered.2728Minor Releases29--------------3029A minor release will not include breaking changes but may include30miscellaneous bug fixes and upgrades to vendored packages. If the previous31version of Requests released was ``v10.2.7`` a minor release would be32versioned as ``v10.3.0``.31A minor release will not include breaking changes but may include miscellaneous32bug fixes. If the previous version of Requests released was ``v10.2.7`` a minor33release would be versioned as ``v10.3.0``.3435Minor releases will be backwards compatible with releases that have the same36major version number. In other words, all versions that would start with37``v10.`` should be compatible with each other.
18 unmodified lines
added:docs/community/sponsors.rst+96 added
1Community Sponsors2==================34**tl;dr**: Requests development is currently `funded by the Python community <https://www.kennethreitz.org/requests3>`_, and5some wonderful organizations that utilize the software in their businesses.678-------------------91011Requests is one of the most heavily–utilized Python packages in the world.1213It is used by major corporations worldwide for all tasks, both small and large — from writing one–off scripts to orchestrating millions of dollars of critical infrastructure.1415It's even embedded within pip, that tool that you use to install packages and deploy with every day!1617After losing our primary open source maintainer (who was sponsored by a company to work on Requests, and other projects, full–time), we are seeking community financial contributions towards the development of Requests 3.0.1819Patron Sponsors20----------------212223`Linode — SSD Cloud Hosting & Linux Servers <https://www.linode.com>`_24//////////////////////////////////////////////////////////////////////2526Whether you’re just getting started or deploying a complex system, launching a Linode cloud server has never been easier. They offer the fastest hardware and network in the industry with scalable environments, and their 24x7 customer support team is always standing by to help with any questions.2728✨🍰✨29//////3031----------------------------------3233This slot is reserved for ethical organizations willing to invest $10,000 or more in Requests per year.3435By becoming a patron–level sponsor, your organization will receive the following benefits:3637- Prominent placement on the Requests documentation sidebar (~11,000 uniques / day).38- Honorable mention here, with logo.39- Peace of mind knowing that the infrastructure you rely on is being actively maintained.4041Organizations that sign up will be listed in order — first come first serve!4243Major Sponsors44--------------4546The following organizations have significantly contributed towards Requests' sustainability:4748`Slack — Bring your team together <https://slack.com>`_49///////////////////////////////////////////////////////5051Slack was extremely kind to be the first organization to generously donate a large sum towards the `2018 Requests 3.0 fundraiser <https://www.kennethreitz.org/requests3>`_, surpassing our entire fundraising goal immediately! They are helping the world become a better place through connectiveness, and reducing the amount of email we all have52to deal with on a daily basis.5354P.S. They're `hiring <https://slack.com/careers#openings>`_!555657`Twilio — Voice, SMS, and Video for Humans <https://www.twilio.com>`_58/////////////////////////////////////////////////////////////////////5960Twilio was the second organization to generously donate a large sum towards the `2018 Requests 3.0 fundraiser <https://www.kennethreitz.org/requests3>`_, matching the donation of Slack! They are helping the world become a better place through interconnectivity,61providing easy–to–use APIs, and empowering developers world-over to help humans communicate in meaningful and effictive ways.626364`Azure Cloud Developer Advocates <https://developer.microsoft.com/en-us/advocates/>`_65/////////////////////////////////////////////////////////////////////////////////////6667Azure was the third organization to generously donate a large sum towards the `2018 Requests 3.0 fundraiser <https://www.kennethreitz.org/requests3>`_, matching the donation of Twilio! Awesome group of generous folks :)686970`Niteo — Web Systems Development <https://www.niteoweb.com>`_71/////////////////////////////////////////////////////////////7273Niteo was the fourth company to generously donate towards the `2018 Requests 3.0 fundraiser <https://www.kennethreitz.org/requests3>`_. Niteo is a company employing tech enthusiasts from all over the world74who love to build great stuff.757677`Heroku <https://heroku.com/python>`_78/////////////////////////////////////7980Heroku has allowed Kenneth Reitz to work on some open source projects during work hours,81including Requests (but mostly Pipenv), from time–to–time, so they are listed82here as an honorable mention.8384----------------8586If your organization is interested in becoming either a sponsor or a patron, please `send us an email <mailto:me@kennethreitz.org>`_.878889Individual Sponsors90-------------------9192Countless individuals, too many to list here, have individually contributed towards the sustainability of the Requests93project over the years. Some, financially, others, with code. Contributions (from humans) of all kinds are greatly94appreciated.9596✨🍰✨
modified:docs/community/support.rst+8 added-5 removed
1 unmodified line
23Support4=======56.. image:: https://farm5.staticflickr.com/4198/34080352913_5c13ffb336_k_d.jpg78If you have questions or issues about Requests, there are several options:98StackOverflow10Stack Overflow11-------------1213If your question does not contain sensitive (possibly proprietary)14information or can be properly anonymized, please ask a question on13`StackOverflow <https://stackoverflow.com/questions/tagged/python-requests>`_15`Stack Overflow <https://stackoverflow.com/questions/tagged/python-requests>`_16and use the tag ``python-requests``.1718Send a Tweet19------------2019If your question is less than 140 characters, feel free to send a tweet to21If your question is less than 280 characters, feel free to send a tweet to22`@kennethreitz <https://twitter.com/kennethreitz>`_,21`@sigmavirus24 <https://twitter.com/sigmavirus24>`_, or22`@lukasaoz <https://twitter.com/lukasaoz>`_.23`@sigmavirus24 <https://twitter.com/sigmavirus24>`_,24`@lukasaoz <https://twitter.com/lukasaoz>`_, or25`@nateprewitt <https://twitter.com/nateprewitt>`_.2627File an Issue28-------------29
25 unmodified lines
modified:docs/community/updates.rst+3 added-2 removed
2 unmodified lines
34Community Updates5=================67.. image:: https://farm5.staticflickr.com/4244/34080354873_516c283ad0_k_d.jpg89If you'd like to stay up to date on the community and development of Requests,10there are several options:1112
14 unmodified lines
2728Release and Version History29===========================3029.. include:: ../../HISTORY.rst3031.. include:: ../../HISTORY.md
modified:docs/community/vulnerabilities.rst+10 added-5 removed
1Vulnerability Disclosure2========================34.. image:: https://farm5.staticflickr.com/4211/34709353644_b041e9e1c2_k_d.jpg56If you think you have found a potential security vulnerability in requests,7please email `sigmavirus24 <mailto:graffatcolmingov@gmail.com>`_ and6`Lukasa <mailto:cory@lukasa.co.uk>`_ directly. **Do not file a public issue.**8`Nate <mailto:nate.prewitt@gmail.com>`_ directly. **Do not file a public issue.**910Our PGP Key fingerprints are:1112- 0161 BB7E B208 B5E0 4FDC 9F81 D9DA 0A04 9113 F853 (@sigmavirus24)1312- 90DC AE40 FEA7 4B14 9B70 662D F25F 2144 EEC1 373D (@lukasa)14- 8722 7E29 AD9C FF5C FAC3 EA6A 44D3 FF97 B80D C864 (@nateprewitt)1516If English is not your first language, please try to describe the problem and17its impact to the best of your ability. For greater detail, please use your18native language and we will try our best to translate it using online services.
75 unmodified lines
9495Previous CVEs96-------------9798- Fixed in 2.20.099 - `CVE 2018-18074 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=2018-18074>`_100101- Fixed in 2.6.010298 - `CVE 2015-2296 <http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=2015-2296>`_,103 - `CVE 2015-2296 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=2015-2296>`_,104 reported by Matthew Daley of `BugFuzz <https://bugfuzz.com/>`_.105106- Fixed in 2.3.0107103 - `CVE 2014-1829 <http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=2014-1829>`_108 - `CVE 2014-1829 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=2014-1829>`_109105 - `CVE 2014-1830 <http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=2014-1830>`_110 - `CVE 2014-1830 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=2014-1830>`_
modified:docs/dev/authors.rst+1 added
1Authors2=======34.. image:: https://static1.squarespace.com/static/533ad9bde4b098d084a846b1/t/534f6e1ce4b09b70f38ee6c1/1432265542589/DSCF3147.jpg?format=2500w56.. include:: ../../AUTHORS.rst
modified:docs/dev/contributing.rst+8 added-5 removed
1 unmodified line
23Contributor's Guide4===================56.. image:: https://farm5.staticflickr.com/4237/35550408335_7671fde302_k_d.jpg78If you're reading this, you're probably interested in contributing to Requests.9Thank you very much! Open source projects live-and-die based on the support10they receive from others, and the fact that you're even considering11contributing to the Requests project is *very* generous of you.1213This document lays out guidelines and advice for contributing to this project.14If you're thinking of contributing, please start by reading this document and15getting a feel for how contributing to this project works. If you have any14questions, feel free to reach out to either `Ian Cordasco`_ or `Cory Benfield`_,15the primary maintainers.16questions, feel free to reach out to either `Ian Cordasco`_, `Cory Benfield`_,17or `Nate Prewitt`_, the primary maintainers.1819.. _Ian Cordasco: http://www.coglib.com/~icordasc/20.. _Cory Benfield: https://lukasa.co.uk/about21.. _Nate Prewitt: https://www.nateprewitt.com/2223If you have non-technical feedback, philosophical ponderings, crazy ideas, or24other general thoughts about Requests or its position within the Python25ecosystem, the BDFL, `Kenneth Reitz`_, would love to hear from you.
15 unmodified lines
4142**All contributions are welcome**, as long as43everyone involved is treated with respect.4442.. _be cordial or be on your way: http://kennethreitz.org/be-cordial-or-be-on-your-way/45.. _be cordial or be on your way: https://www.kennethreitz.org/essays/be-cordial-or-be-on-your-way4647.. _early-feedback:4849Get Early Feedback
107 unmodified lines
157model methods (e.g. ``__repr__``) are typically the exception to this rule.158159Thanks for helping to make the world a better place!160158.. _PEP 8: http://pep8.org161.. _PEP 8: https://pep8.org/162.. _line continuations: https://www.python.org/dev/peps/pep-0008/#indentation163164Documentation Contributions165---------------------------
39 unmodified lines
205while keeping an open ear and mind.206207If you believe there is a feature missing, feel free to raise a feature208request, but please do be aware that the overwhelming likelihood is that your206feature request will not be accepted.209feature request will not be accepted.
modified:docs/dev/philosophy.rst+9 added-3 removed
1Development Philosophy2======================34.. image:: https://farm5.staticflickr.com/4231/34484831073_636008a23d_k_d.jpg56Requests is an open but opinionated library, created by an open but opinionated developer.789Management Style10~~~~~~~~~~~~~~~~1110`Kenneth Reitz <http://kennethreitz.org>`_ is the BDFL. He has final say in any decision related to the Requests project. Kenneth is responsible for the direction and form of the library, as well as its presentation. In addition to making decisions based on technical merit, he is responsible for making decisions based on the development philosophy of Requests.12`Kenneth Reitz <https://www.kennethreitz.org/>`_ is the BDFL. He has final say in any decision related to the Requests project. Kenneth is responsible for the direction and form of the library, as well as its presentation. In addition to making decisions based on technical merit, he is responsible for making decisions based on the development philosophy of Requests.1312`Ian Cordasco <http://www.coglib.com/~icordasc/>`_ and `Cory Benfield <https://lukasa.co.uk/about/>`_ are the core contributors. They are responsible for triaging bug reports, reviewing pull requests and ensuring that Kenneth is kept up to speed with developments around the library. The day-to-day managing of the project is done by the core contributors. They are responsible for making judgements about whether or not a feature request is likely to be accepted by Kenneth. Their word is, in some ways, more final than Kenneth's.14`Ian Cordasco <http://www.coglib.com/~icordasc/>`_, `Cory Benfield <https://lukasa.co.uk/about/>`_, and `Nate Prewitt <https://www.nateprewitt.com/>`_ are the core contributors. They are responsible for triaging bug reports, reviewing pull requests and ensuring that Kenneth is kept up to speed with developments around the library. The day-to-day managing of the project is done by the core contributors. They are responsible for making judgements about whether or not a feature request is likely to be accepted by Kenneth. Their word is, in some ways, more final than Kenneth's.1516Values17~~~~~~18
6 unmodified lines
25~~~~~~~~~~~~~~~~~~~2627For many years, the open source community has been plagued with version number dystonia. Numbers vary so greatly from project to project, they are practically meaningless.2827Requests uses `Semantic Versioning <http://semver.org>`_. This specification seeks to put an end to this madness with a small set of practical guidelines for you and your colleagues to use in your next project.29Requests uses `Semantic Versioning <https://semver.org/>`_. This specification seeks to put an end to this madness with a small set of practical guidelines for you and your colleagues to use in your next project.3031Standard Library?32~~~~~~~~~~~~~~~~~3334Requests has no *active* plans to be included in the standard library. This decision has been discussed at length with Guido as well as numerous core developers.3536.. raw:: html3738 <script async class="speakerdeck-embed" data-id="68f22f0841734d848315c618111b13ea" data-ratio="1.33333333333333" src="//speakerdeck.com/assets/embed.js"></script>3940Essentially, the standard library is where a library goes to die. It is appropriate for a module to be included when active development is no longer necessary.4142Linux Distro Packages43~~~~~~~~~~~~~~~~~~~~~
4 unmodified lines
modified:docs/dev/todo.rst+4 added-4 removed
1How to Help2===========34.. image:: https://farm5.staticflickr.com/4290/34450900104_bc1d424213_k_d.jpg56Requests is under active development, and contributions are more than welcome!78#. Check for open issues or open a fresh issue to start a discussion around a bug.9 There is a Contributor Friendly tag for issues that should be ideal for people who are not very
40 unmodified lines
50--------------------5152Requests currently supports the following versions of Python:5352- Python 2.654- Python 2.754- Python 3.355- Python 3.456- Python 3.557- Python 3.658- Python 3.759- PyPy6061Google AppEngine is not officially supported although support is available62with the `Requests-Toolbelt`_.6363.. _Requests-Toolbelt: http://toolbelt.readthedocs.io/6464.. _Requests-Toolbelt: https://toolbelt.readthedocs.io/
modified:docs/user/advanced.rst+89 added-48 removed
1 unmodified line
23Advanced Usage4==============56.. image:: https://farm5.staticflickr.com/4263/35163665790_d182d84f5e_k_d.jpg78This document covers some of Requests more advanced features.910.. _session-objects:11
12 unmodified lines
24Let's persist some cookies across requests::2526 s = requests.Session()2726 s.get('http://httpbin.org/cookies/set/sessioncookie/123456789')27 r = s.get('http://httpbin.org/cookies')28 s.get('https://httpbin.org/cookies/set/sessioncookie/123456789')29 r = s.get('https://httpbin.org/cookies')3031 print(r.text)32 # '{"cookies": {"sessioncookie": "123456789"}}'33
5 unmodified lines
39 s.auth = ('user', 'pass')40 s.headers.update({'x-test': 'true'})4142 # both 'x-test' and 'x-test2' are sent41 s.get('http://httpbin.org/headers', headers={'x-test2': 'true'})43 s.get('https://httpbin.org/headers', headers={'x-test2': 'true'})444546Any dictionaries that you pass to a request method will be merged with the47session-level values that are set. The method-level parameters override session
4 unmodified lines
52with the first request, but not the second::5354 s = requests.Session()5554 r = s.get('http://httpbin.org/cookies', cookies={'from-my': 'browser'})56 r = s.get('https://httpbin.org/cookies', cookies={'from-my': 'browser'})57 print(r.text)58 # '{"cookies": {"from-my": "browser"}}'5958 r = s.get('http://httpbin.org/cookies')60 r = s.get('https://httpbin.org/cookies')61 print(r.text)62 # '{"cookies": {}}'6364
3 unmodified lines
6869Sessions can also be used as context managers::7071 with requests.Session() as s:70 s.get('http://httpbin.org/cookies/set/sessioncookie/123456789')72 s.get('https://httpbin.org/cookies/set/sessioncookie/123456789')7374This will make sure the session is closed as soon as the ``with`` block is75exited, even if unhandled exceptions occurred.76
19 unmodified lines
96The ``Response`` object contains all of the information returned by the server and97also contains the ``Request`` object you created originally. Here is a simple98request to get some very important information from Wikipedia's servers::9998 >>> r = requests.get('http://en.wikipedia.org/wiki/Monty_Python')100 >>> r = requests.get('https://en.wikipedia.org/wiki/Monty_Python')101102If we want to access the headers the server sent back to us, we do this::103104 >>> r.headers
83 unmodified lines
188 )189190 print(resp.status_code)191192When you are using the prepared request flow, keep in mind that it does not take into account the environment.193This can cause problems if you are using environment variables to change the behaviour of requests.194For example: Self-signed SSL certificates specified in ``REQUESTS_CA_BUNDLE`` will not be taken into account.195As a result an ``SSL: CERTIFICATE_VERIFY_FAILED`` is thrown.196You can get around this behaviour by explicity merging the environment settings into your session::197198 from requests import Request, Session199200 s = Session()201 req = Request('GET', url)202203 prepped = s.prepare_request(req)204205 # Merge environment settings into session206 settings = s.merge_environment_settings(prepped.url, None, None, None, None)207 resp = s.send(prepped, **settings)208209 print(resp.status_code)210211.. _verification:212213SSL Cert Verification214---------------------
58 unmodified lines
273274CA Certificates275---------------276256By default, Requests bundles a set of root CAs that it trusts, sourced from the257`Mozilla trust store`_. However, these are only updated once for each Requests258version. This means that if you pin a Requests version your certificates can259become extremely out of date.277Requests uses certificates from the package `certifi`_. This allows for users278to update their trusted certificates without changing the version of Requests.279261From Requests version 2.4.0 onwards, Requests will attempt to use certificates262from `certifi`_ if it is present on the system. This allows for users to update263their trusted certificates without having to change the code that runs on their264system.280Before version 2.16, Requests bundled a set of root CAs that it trusted,281sourced from the `Mozilla trust store`_. The certificates were only updated282once for each Requests version. When ``certifi`` was not installed, this led to283extremely out-of-date certificate bundles when using significantly older284versions of Requests.285286For the sake of security we recommend upgrading certifi frequently!287288.. _HTTP persistent connection: https://en.wikipedia.org/wiki/HTTP_persistent_connection269.. _connection pooling: http://urllib3.readthedocs.io/en/latest/reference/index.html#module-urllib3.connectionpool270.. _certifi: http://certifi.io/289.. _connection pooling: https://urllib3.readthedocs.io/en/latest/reference/index.html#module-urllib3.connectionpool290.. _certifi: https://certifiio.readthedocs.io/291.. _Mozilla trust store: https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt292293.. _body-content-workflow:294
27 unmodified lines
322inefficiency with connections. If you find yourself partially reading request323bodies (or not reading them at all) while using ``stream=True``, you should324make the request within a ``with`` statement to ensure it's always closed::325306 with requests.get('http://httpbin.org/get', stream=True) as r:326 with requests.get('https://httpbin.org/get', stream=True) as r:327 # Do things with the response here.328329.. _keep-alive:330
19 unmodified lines
350351 with open('massive-body', 'rb') as f:352 requests.post('http://some.url/streamed', data=f)353334.. warning:: It is strongly recommended that you open files in `binary mode`_.335 This is because Requests may attempt to provide the336 ``Content-Length`` header for you, and if it does this value will337 be set to the number of *bytes* in the file. Errors may occur if338 you open the file in *text mode*.354.. warning:: It is strongly recommended that you open files in :ref:`binary355 mode <tut-files>`. This is because Requests may attempt to provide356 the ``Content-Length`` header for you, and if it does this value357 will be set to the number of *bytes* in the file. Errors may occur358 if you open the file in *text mode*.359340.. _binary mode: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files360342361.. _chunk-encoding:362363Chunk-Encoded Requests364----------------------
27 unmodified lines
392 <input type="file" name="images" multiple="true" required="true"/>393394To do that, just set files to a list of tuples of ``(form_field_name, file_info)``::395378 >>> url = 'http://httpbin.org/post'396 >>> url = 'https://httpbin.org/post'397 >>> multiple_files = [398 ('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),399 ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]400 >>> r = requests.post(url, files=multiple_files)
4 unmodified lines
405 'Content-Type': 'multipart/form-data; boundary=3131623adb2043caaeb5538cc7aa0b3a',406 ...407 }408391.. warning:: It is strongly recommended that you open files in `binary mode`_.392 This is because Requests may attempt to provide the393 ``Content-Length`` header for you, and if it does this value will394 be set to the number of *bytes* in the file. Errors may occur if395 you open the file in *text mode*.409.. warning:: It is strongly recommended that you open files in :ref:`binary410 mode <tut-files>`. This is because Requests may attempt to provide411 the ``Content-Length`` header for you, and if it does this value412 will be set to the number of *bytes* in the file. Errors may occur413 if you open the file in *text mode*.414397.. _binary mode: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files415399416.. _event-hooks:417418Event Hooks419-----------
10 unmodified lines
430You can assign a hook function on a per-request basis by passing a431``{hook_name: callback_function}`` dictionary to the ``hooks`` request432parameter::433418 hooks=dict(response=print_url)434 hooks={'response': print_url}435436That ``callback_function`` will receive a chunk of data as its first437argument.438
5 unmodified lines
444If an error occurs while executing your callback, a warning is given.445446If the callback function returns a value, it is assumed that it is to447replace the data that was passed in. If the function doesn't return432anything, nothing else is effected.448anything, nothing else is affected.449450::451452 def record_hook(r, *args, **kwargs):453 r.hook_called = True454 return r455456Let's print some request method arguments at runtime::457436 >>> requests.get('http://httpbin.org', hooks=dict(response=print_url))437 http://httpbin.org458 >>> requests.get('https://httpbin.org/', hooks={'response': print_url})459 https://httpbin.org/460 <Response [200]>461462You can add multiple hooks to a single request. Let's call two hooks at once::463464 >>> r = requests.get('https://httpbin.org/', hooks={'response': [print_url, record_hook]})465 >>> r.hook_called466 True467468You can also add hooks to a ``Session`` instance. Any hooks you add will then469be called on every request made to the session. For example::470471 >>> s = requests.Session()472 >>> s.hooks['response'].append(print_url)473 >>> s.get('https://httpbin.org/')474 https://httpbin.org/475 <Response [200]>476477A ``Session`` can have multiple hooks, which will be called in the order478they are added.479480.. _custom-auth:481482Custom Authentication483---------------------
44 unmodified lines
528529 import json530 import requests531492 r = requests.get('http://httpbin.org/stream/20', stream=True)532 r = requests.get('https://httpbin.org/stream/20', stream=True)533534 for line in r.iter_lines():535536 # filter out keep-alive new lines
5 unmodified lines
542:meth:`Response.iter_lines() <requests.Response.iter_lines>` or543:meth:`Response.iter_content() <requests.Response.iter_content>`, you'll want544to provide a fallback encoding in the event the server doesn't provide one::545506 r = requests.get('http://httpbin.org/stream/20', stream=True)546 r = requests.get('https://httpbin.org/stream/20', stream=True)547548 if r.encoding is None:549 r.encoding = 'utf-8'550
100 unmodified lines
651When you receive a response, Requests makes a guess at the encoding to652use for decoding the response when you access the :attr:`Response.text653<requests.Response.text>` attribute. Requests will first check for an654encoding in the HTTP header, and if none is present, will use `chardet615<http://pypi.python.org/pypi/chardet>`_ to attempt to guess the encoding.655<https://pypi.org/project/chardet/>`_ to attempt to guess the encoding.656657The only time Requests will not do this is if no explicit charset658is present in the HTTP headers **and** the ``Content-Type``659header contains ``text``. In this situation, `RFC 2616620<http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1>`_ specifies660<https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1>`_ specifies661that the default charset must be ``ISO-8859-1``. Requests follows the662specification in this case. If you require a different encoding, you can663manually set the :attr:`Response.encoding <requests.Response.encoding>`664property, or use the raw :attr:`Response.content <requests.Response.content>`.
213 unmodified lines
878879Many HTTP APIs feature Link headers. They make APIs more self describing and880discoverable.881842GitHub uses these for `pagination <http://developer.github.com/v3/#pagination>`_882GitHub uses these for `pagination <https://developer.github.com/v3/#pagination>`_883in their API, for example::884885 >>> url = 'https://api.github.com/users/kennethreitz/repos?page=1&per_page=10'886 >>> r = requests.head(url=url)
33 unmodified lines
920921::922923 >>> s = requests.Session()884 >>> s.mount('http://www.github.com', MyAdapter())924 >>> s.mount('https://github.com/', MyAdapter())925926The mount call registers a specific instance of a Transport Adapter to a927prefix. Once mounted, any HTTP request made using that session whose URL starts928with the given prefix will use the given Transport Adapter.
16 unmodified lines
945passed-through to `urllib3`. We'll make a Transport Adapter that instructs the946library to use SSLv3::947948 import ssl949 from urllib3.poolmanager import PoolManager950951 from requests.adapters import HTTPAdapter911 from requests.packages.urllib3.poolmanager import PoolManager952953954 class Ssl3HttpAdapter(HTTPAdapter):955 """"Transport adapter" that allows us to use SSLv3."""
2 unmodified lines
958 self.poolmanager = PoolManager(959 num_pools=connections, maxsize=maxsize,960 block=block, ssl_version=ssl.PROTOCOL_SSLv3)961922.. _`described here`: http://www.kennethreitz.org/essays/the-future-of-python-http962.. _`described here`: https://www.kennethreitz.org/essays/the-future-of-python-http963.. _`urllib3`: https://github.com/shazow/urllib3964965.. _blocking-or-nonblocking:966
8 unmodified lines
975response at a time. However, these calls will still block.976977If you are concerned about the use of blocking IO, there are lots of projects978out there that combine Requests with one of Python's asynchronicity frameworks.939Two excellent examples are `grequests`_ and `requests-futures`_.979Some excellent examples are `requests-threads`_, `grequests`_, and `requests-futures`_.980981.. _`requests-threads`: https://github.com/requests/requests-threads982.. _`grequests`: https://github.com/kennethreitz/grequests983.. _`requests-futures`: https://github.com/ross/requests-futures984985Header Ordering
16 unmodified lines
1002The **connect** timeout is the number of seconds Requests will wait for your1003client to establish a connection to a remote machine (corresponding to the1004`connect()`_) call on the socket. It's a good practice to set connect timeouts1005to slightly larger than a multiple of 3, which is the default `TCP packet965retransmission window <http://www.hjp.at/doc/rfc/rfc2988.txt>`_.1006retransmission window <https://www.hjp.at/doc/rfc/rfc2988.txt>`_.10071008Once your client has connected to the server and sent the HTTP request, the1009**read** timeout is the number of seconds the client will wait for the server1010to send a response. (Specifically, it's the number of seconds that the client
16 unmodified lines
1027::10281029 r = requests.get('https://github.com', timeout=None)1030990.. _`connect()`: http://linux.die.net/man/2/connect1031.. _`connect()`: https://linux.die.net/man/2/connect
modified:docs/user/authentication.rst+10 added-8 removed
1 unmodified line
23Authentication4==============56.. image:: https://farm5.staticflickr.com/4258/35550409215_3b08d49d22_k_d.jpg78This document discusses using various kinds of authentication with Requests.910Many web services require authentication, and there are many different types.11Below, we outline various forms of authentication available in Requests, from
40 unmodified lines
52Another very popular form of HTTP Authentication is Digest Authentication,53and Requests supports this out of the box as well::5455 >>> from requests.auth import HTTPDigestAuth54 >>> url = 'http://httpbin.org/digest-auth/auth/user/pass'56 >>> url = 'https://httpbin.org/digest-auth/auth/user/pass'57 >>> requests.get(url, auth=HTTPDigestAuth('user', 'pass'))58 <Response [200]>5960
60 unmodified lines
121 ... def __call__(self, r):122 ... # Implement my authentication123 ... return r124 ...123 >>> url = 'http://httpbin.org/get'125 >>> url = 'https://httpbin.org/get'126 >>> requests.get(url, auth=MyAuth())127 <Response [200]>128129When an authentication handler is attached to a request,
3 unmodified lines
133134Further examples can be found under the `Requests organization`_ and in the135``auth.py`` file.136135.. _OAuth: http://oauth.net/137.. _OAuth: https://oauth.net/138.. _requests_oauthlib: https://github.com/requests/requests-oauthlib137.. _requests-oauthlib OAuth2 documentation: http://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html138.. _Web Application Flow: http://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#web-application-flow139.. _Mobile Application Flow: http://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#mobile-application-flow140.. _Legacy Application Flow: http://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#legacy-application-flow141.. _Backend Application Flow: http://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#backend-application-flow139.. _requests-oauthlib OAuth2 documentation: https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html140.. _Web Application Flow: https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#web-application-flow141.. _Mobile Application Flow: https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#mobile-application-flow142.. _Legacy Application Flow: https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#legacy-application-flow143.. _Backend Application Flow: https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#backend-application-flow144.. _Kerberos: https://github.com/requests/requests-kerberos145.. _NTLM: https://github.com/requests/requests-ntlm146.. _Requests organization: https://github.com/requests
modified:docs/user/install.rst+8 added-5 removed
1 unmodified line
23Installation of Requests4========================56.. image:: https://farm5.staticflickr.com/4230/35550376215_da1bf77a8c_k_d.jpg789This part of the documentation covers the installation of Requests.10The first step to using any software package is getting it properly installed.111210$ pip install requests11----------------------13$ pipenv install requests14-------------------------1516To install Requests, simply run this simple command in your terminal of choice::1715 $ pip install requests18 $ pipenv install requests1917If you don't have `pip <https://pip.pypa.io>`_ installed (tisk tisk!),18`this Python installation guide <http://docs.python-guide.org/en/latest/starting/installation/>`_20If you don't have `pipenv <http://pipenv.org/>`_ installed (tisk tisk!), head over to the Pipenv website for installation instructions. Or, if you prefer to just use pip and don't have it installed,21`this Python installation guide <https://docs.python-guide.org/starting/installation/>`_22can guide you through the process.2324Get the Source Code25-------------------
18 unmodified lines
modified:docs/user/intro.rst+4 added-2 removed
1 unmodified line
23Introduction4============56.. image:: https://farm5.staticflickr.com/4317/35198386374_1939af3de6_k_d.jpg78Philosophy9----------1011Requests was developed with a few :pep:`20` idioms in mind.
24 unmodified lines
36closed-source software.3738Requests is released under terms of `Apache2 License`_.3938.. _`GPL Licensed`: http://www.opensource.org/licenses/gpl-license.php39.. _`Apache2 License`: http://opensource.org/licenses/Apache-2.040.. _`GPL Licensed`: https://opensource.org/licenses/gpl-license.php41.. _`Apache2 License`: https://opensource.org/licenses/Apache-2.0424344Requests License45----------------
2 unmodified lines
modified:docs/user/quickstart.rst+54 added-37 removed
1 unmodified line
23Quickstart4==========56.. image:: https://farm5.staticflickr.com/4259/35163667010_8bfcaef274_k_d.jpg78.. module:: requests.models910Eager to get started? This page gives a good introduction in how to get started11with Requests.
26 unmodified lines
3839Requests' simple API means that all forms of HTTP request are as obvious. For40example, this is how you make an HTTP POST request::4140 >>> r = requests.post('http://httpbin.org/post', data = {'key':'value'})42 >>> r = requests.post('https://httpbin.org/post', data = {'key':'value'})4344Nice, right? What about the other HTTP request types: PUT, DELETE, HEAD and45OPTIONS? These are all just as simple::4645 >>> r = requests.put('http://httpbin.org/put', data = {'key':'value'})46 >>> r = requests.delete('http://httpbin.org/delete')47 >>> r = requests.head('http://httpbin.org/get')48 >>> r = requests.options('http://httpbin.org/get')47 >>> r = requests.put('https://httpbin.org/put', data = {'key':'value'})48 >>> r = requests.delete('https://httpbin.org/delete')49 >>> r = requests.head('https://httpbin.org/get')50 >>> r = requests.options('https://httpbin.org/get')5152That's all well and good, but it's also only the start of what Requests can53do.54
9 unmodified lines
64``key1=value1`` and ``key2=value2`` to ``httpbin.org/get``, you would use the65following code::6667 >>> payload = {'key1': 'value1', 'key2': 'value2'}66 >>> r = requests.get('http://httpbin.org/get', params=payload)68 >>> r = requests.get('https://httpbin.org/get', params=payload)6970You can see that the URL has been correctly encoded by printing the URL::7172 >>> print(r.url)71 http://httpbin.org/get?key2=value2&key1=value173 https://httpbin.org/get?key2=value2&key1=value17475Note that any dictionary key whose value is ``None`` will not be added to the76URL's query string.7778You can also pass a list of items as a value::7980 >>> payload = {'key1': 'value1', 'key2': ['value2', 'value3']}8180 >>> r = requests.get('http://httpbin.org/get', params=payload)82 >>> r = requests.get('https://httpbin.org/get', params=payload)83 >>> print(r.url)82 http://httpbin.org/get?key1=value1&key2=value2&key2=value384 https://httpbin.org/get?key1=value1&key2=value2&key2=value38586Response Content87----------------88
20 unmodified lines
109110If you change the encoding, Requests will use the new value of ``r.encoding``111whenever you call ``r.text``. You might want to do this in any situation where112you can apply special logic to work out what the encoding of the content will111be. For example, HTTP and XML have the ability to specify their encoding in113be. For example, HTML and XML have the ability to specify their encoding in114their body. In situations like this, you should use ``r.content`` to find the115encoding, and then set ``r.encoding``. This will let you use ``r.text`` with116the correct encoding.117
52 unmodified lines
170171 >>> r = requests.get('https://api.github.com/events', stream=True)172173 >>> r.raw172 <requests.packages.urllib3.response.HTTPResponse object at 0x101194810>174 <urllib3.response.HTTPResponse object at 0x101194810>175176 >>> r.raw.read(10)177 '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03'178
9 unmodified lines
188download, the above is the preferred and recommended way to retrieve the189content. Note that ``chunk_size`` can be freely adjusted to a number that190may better fit your use cases.191192.. note::193194 An important note about using ``Response.iter_content`` versus ``Response.raw``.195 ``Response.iter_content`` will automatically decode the ``gzip`` and ``deflate``196 transfer-encodings. ``Response.raw`` is a raw stream of bytes -- it does not197 transform the response content. If you really need access to the bytes as they198 were returned, use ``Response.raw``.199200201Custom Headers202--------------203204If you'd like to add HTTP headers to a request, simply pass in a ``dict`` to the
27 unmodified lines
232dictionary of data will automatically be form-encoded when the request is made::233234 >>> payload = {'key1': 'value1', 'key2': 'value2'}235226 >>> r = requests.post("http://httpbin.org/post", data=payload)236 >>> r = requests.post("https://httpbin.org/post", data=payload)237 >>> print(r.text)238 {239 ...240 "form": {
2 unmodified lines
243 },244 ...245 }246237You can also pass a list of tuples to the ``data`` argument. This is particularly238useful when the form has multiple elements that use the same key::247The ``data`` argument can also have multiple values for each key. This can be248done by making ``data`` either a list of tuples or a dictionary with lists249as values. This is particularly useful when the form has multiple elements that250use the same key::251240 >>> payload = (('key1', 'value1'), ('key1', 'value2'))241 >>> r = requests.post('http://httpbin.org/post', data=payload)242 >>> print(r.text)252 >>> payload_tuples = [('key1', 'value1'), ('key1', 'value2')]253 >>> r1 = requests.post('https://httpbin.org/post', data=payload_tuples)254 >>> payload_dict = {'key1': ['value1', 'value2']}255 >>> r2 = requests.post('https://httpbin.org/post', data=payload_dict)256 >>> print(r1.text)257 {258 ...259 "form": {260 "key1": [
2 unmodified lines
263 ]264 },265 ...266 }267 >>> r1.text == r2.text268 True269270There are times that you may want to send data that is not form-encoded. If271you pass in a ``string`` instead of a ``dict``, that data will be posted directly.272
13 unmodified lines
286 >>> payload = {'some': 'data'}287288 >>> r = requests.post(url, json=payload)289290Note, the ``json`` parameter is ignored if either ``data`` or ``files`` is passed.291292Using the ``json`` parameter in the request will change the ``Content-Type`` in the header to ``application/json``.293294POST a Multipart-Encoded File295-----------------------------296297Requests makes it simple to upload Multipart-encoded files::298280 >>> url = 'http://httpbin.org/post'299 >>> url = 'https://httpbin.org/post'300 >>> files = {'file': open('report.xls', 'rb')}301302 >>> r = requests.post(url, files=files)303 >>> r.text
6 unmodified lines
310 }311312You can set the filename, content_type and headers explicitly::313295 >>> url = 'http://httpbin.org/post'314 >>> url = 'https://httpbin.org/post'315 >>> files = {'file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})}316317 >>> r = requests.post(url, files=files)318 >>> r.text
6 unmodified lines
325 }326327If you want, you can send strings to be received as files::328310 >>> url = 'http://httpbin.org/post'329 >>> url = 'https://httpbin.org/post'330 >>> files = {'file': ('report.csv', 'some,data,to,send\nanother,row,to,send\n')}331332 >>> r = requests.post(url, files=files)333 >>> r.text
13 unmodified lines
347348For sending multiple files in one request refer to the :ref:`advanced <advanced>`349section.350332.. warning:: It is strongly recommended that you open files in `binary mode`_.333 This is because Requests may attempt to provide the334 ``Content-Length`` header for you, and if it does this value will335 be set to the number of *bytes* in the file. Errors may occur if336 you open the file in *text mode*.351.. warning:: It is strongly recommended that you open files in :ref:`binary352 mode <tut-files>`. This is because Requests may attempt to provide353 the ``Content-Length`` header for you, and if it does this value354 will be set to the number of *bytes* in the file. Errors may occur355 if you open the file in *text mode*.356338.. _binary mode: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files357340358Response Status Codes359---------------------360361We can check the response status code::362346 >>> r = requests.get('http://httpbin.org/get')363 >>> r = requests.get('https://httpbin.org/get')364 >>> r.status_code365 200366367Requests also comes with a built-in status code lookup object for easy
5 unmodified lines
373If we made a bad request (a 4XX client error or 5XX server error response), we374can raise it with375:meth:`Response.raise_for_status() <requests.Response.raise_for_status>`::376360 >>> bad_r = requests.get('http://httpbin.org/status/404')377 >>> bad_r = requests.get('https://httpbin.org/status/404')378 >>> bad_r.status_code379 404380381 >>> bad_r.raise_for_status()
27 unmodified lines
409 'content-type': 'application/json'410 }411412The dictionary is special, though: it's made just for HTTP headers. According to396`RFC 7230 <http://tools.ietf.org/html/rfc7230#section-3.2>`_, HTTP Header names413`RFC 7230 <https://tools.ietf.org/html/rfc7230#section-3.2>`_, HTTP Header names414are case-insensitive.415416So, we can access the headers using any capitalization we want::417
5 unmodified lines
423424It is also special in that the server could have sent the same header multiple425times with different values, but requests combines them so they can be426represented in the dictionary within a single mapping, as per410`RFC 7230 <http://tools.ietf.org/html/rfc7230#section-3.2>`_:427`RFC 7230 <https://tools.ietf.org/html/rfc7230#section-3.2>`_:428429 A recipient MAY combine multiple header fields with the same field name430 into one "field-name: field-value" pair, without changing the semantics431 of the message, by appending each subsequent field value to the combined
12 unmodified lines
444445To send your own cookies to the server, you can use the ``cookies``446parameter::447431 >>> url = 'http://httpbin.org/cookies'448 >>> url = 'https://httpbin.org/cookies'449 >>> cookies = dict(cookies_are='working')450451 >>> r = requests.get(url, cookies=cookies)452 >>> r.text
6 unmodified lines
459460 >>> jar = requests.cookies.RequestsCookieJar()461 >>> jar.set('tasty_cookie', 'yum', domain='httpbin.org', path='/cookies')462 >>> jar.set('gross_cookie', 'blech', domain='httpbin.org', path='/elsewhere')446 >>> url = 'http://httpbin.org/cookies'463 >>> url = 'https://httpbin.org/cookies'464 >>> r = requests.get(url, cookies=jar)465 >>> r.text466 '{"cookies": {"tasty_cookie": "yum"}}'467
12 unmodified lines
480response.481482For example, GitHub redirects all HTTP requests to HTTPS::483467 >>> r = requests.get('http://github.com')484 >>> r = requests.get('http://github.com/')485486 >>> r.url487 'https://github.com/'488
6 unmodified lines
495496If you're using GET, OPTIONS, POST, PUT, PATCH or DELETE, you can disable497redirection handling with the ``allow_redirects`` parameter::498482 >>> r = requests.get('http://github.com', allow_redirects=False)499 >>> r = requests.get('http://github.com/', allow_redirects=False)500501 >>> r.status_code502 301503
1 unmodified line
505 []506507If you're using HEAD, you can enable redirection as well::508492 >>> r = requests.head('http://github.com', allow_redirects=True)509 >>> r = requests.head('http://github.com/', allow_redirects=True)510511 >>> r.url512 'https://github.com/'513
8 unmodified lines
522seconds with the ``timeout`` parameter. Nearly all production code should use523this parameter in nearly all requests. Failure to do so can cause your program524to hang indefinitely::525509 >>> requests.get('http://github.com', timeout=0.001)526 >>> requests.get('https://github.com/', timeout=0.001)527 Traceback (most recent call last):528 File "<stdin>", line 1, in <module>529 requests.exceptions.Timeout: HTTPConnectionPool(host='github.com', port=80): Request timed out. (timeout=0.001)530
32 unmodified lines
modified:docs/api.rst+7 added-17 removed
107 unmodified lines
108------------------109110.. autoclass:: requests.codes111112::112.. automodule:: requests.status_codes113114 >>> requests.codes['temporary_redirect']115 307114117 >>> requests.codes.teapot118 418119120 >>> requests.codes['\o/']121 200122123124115Migrating to 1.x116----------------117118This section details the main differences between 0.x and 1.x and is meant
19 unmodified lines
138139 s = requests.Session() # formerly, session took parameters140 s.auth = auth141 s.headers.update(headers)152 r = s.get('http://httpbin.org/headers')142 r = s.get('https://httpbin.org/headers')143144* All request hooks have been removed except 'response'.145146* Authentication helpers have been broken out into separate modules. See
33 unmodified lines
180 HTTPConnection.debuglevel = 1181182 logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests183 logging.getLogger().setLevel(logging.DEBUG)194 requests_log = logging.getLogger("requests.packages.urllib3")184 requests_log = logging.getLogger("urllib3")185 requests_log.setLevel(logging.DEBUG)186 requests_log.propagate = True187198 requests.get('http://httpbin.org/headers')188 requests.get('https://httpbin.org/headers')189190191192Licensing
3 unmodified lines
196license from the ISC_ license to the `Apache 2.0`_ license. The Apache 2.0197license ensures that contributions to Requests are also covered by the Apache1982.0 license.199210.. _ISC: http://opensource.org/licenses/ISC211.. _Apache 2.0: http://opensource.org/licenses/Apache-2.0200.. _ISC: https://opensource.org/licenses/ISC201.. _Apache 2.0: https://opensource.org/licenses/Apache-2.0202203204Migrating to 2.x205----------------
6 unmodified lines
212For more details on the changes in this release including new APIs, links213to the relevant GitHub issues and some of the bug fixes, read Cory's blog_214on the subject.215226.. _blog: http://lukasa.co.uk/2013/09/Requests_20/216.. _blog: https://lukasa.co.uk/2013/09/Requests_20/217218219API Changes220~~~~~~~~~~~
40 unmodified lines
modified:docs/conf.py+7 added-3 removed
56 unmodified lines
57master_doc = 'index'5859# General information about the project.60project = u'Requests'61copyright = u'MMXVII. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project'61copyright = u'MMXVIII. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project'62author = u'Kenneth Reitz'6364# The version info for the project you're documenting, acts as replacement for65# |version| and |release|, also used in various other places throughout the
62 unmodified lines
128 'show_powered_by': False,129 'github_user': 'requests',130 'github_repo': 'requests',131 'github_banner': True,132 'show_related': False132 'show_related': False,133 'note_bg': '#FFF59C'134}135136# Add any paths that contain custom themes here, relative to this directory.137#html_theme_path = []
237 unmodified lines
375376# If false, no index is generated.377#epub_use_index = True378378intersphinx_mapping = {'urllib3': ('http://urllib3.readthedocs.io/en/latest', None)}379intersphinx_mapping = {380 'python': ('https://docs.python.org/3/', None),381 'urllib3': ('https://urllib3.readthedocs.io/en/latest', None),382}
modified:docs/index.rst+23 added-15 removed
1 unmodified line
2 sphinx-quickstart on Sun Feb 13 23:54:25 2011.3 You can adapt this file completely to your liking, but it should at least4 contain the root `toctree` directive.56Requests: HTTP for Humans7=========================6Requests: HTTP for Humans™7==========================89Release v\ |version|. (:ref:`Installation <install>`)1011.. image:: https://img.shields.io/pypi/l/requests.svg12 :target: https://pypi.python.org/pypi/requests12 :target: https://pypi.org/project/requests/1314.. image:: https://img.shields.io/pypi/wheel/requests.svg15 :target: https://pypi.python.org/pypi/requests15 :target: https://pypi.org/project/requests/1617.. image:: https://img.shields.io/pypi/pyversions/requests.svg18 :target: https://pypi.python.org/pypi/requests18 :target: https://pypi.org/project/requests/1920.. image:: https://codecov.io/github/requests/requests/coverage.svg?branch=master21 :target: https://codecov.io/github/requests/requests22 :alt: codecov.io
4 unmodified lines
2728**Requests** is the only *Non-GMO* HTTP library for Python, safe for human29consumption.3031*Warning: Recreational use of the Python standard library for HTTP may result in dangerous side-effects,32including: security vulnerabilities, verbose code, reinventing the wheel,33constantly reading documentation, depression, headaches, or even death.*31.. note:: The use of **Python 3** is *highly* preferred over Python 2. Consider upgrading your applications and infrastructure if you find yourself *still* using Python 2 in production today. If you are using Python 3, congratulations — you are indeed a person of excellent taste.32 —*Kenneth Reitz*33 34 35If you're interested in financially supporting Kenneth Reitz open source, consider visiting `this link <https://cash.me/kennethreitz>`_. Your support helps tremendously with sustainability of motivation, as Open Source is no longer part of my day job.363738-------------------3940**Behold, the power of Requests**::41
19 unmodified lines
6162User Testimonials63-----------------6462Twitter, Spotify, Microsoft, Amazon, Lyft, BuzzFeed, Reddit, The NSA, Her Majesty's Government, Google, Twilio, Runscope, Mozilla, Heroku,65Nike, Twitter, Spotify, Microsoft, Amazon, Lyft, BuzzFeed, Reddit, The NSA, Her Majesty's Government, Google, Twilio, Runscope, Mozilla, Heroku,66PayPal, NPR, Obama for America, Transifex, Native Instruments, The Washington67Post, SoundCloud, Kippt, Sony, and Federal U.S.68Institutions that prefer to be unnamed claim to use Requests internally.6967**Armin Ronacher**—70**Armin Ronacher**, creator of Flask—71 *Requests is the perfect example how beautiful an API can be with the72 right level of abstraction.*7374**Matt DeBoard**—
1 unmodified line
76 on my body, somehow. The whole thing.*7778**Daniel Greenfeld**—79 *Nuked a 1200 LOC spaghetti code library with 10 lines of code thanks to77 Kenneth Reitz's request library. Today has been AWESOME.*80 Kenneth Reitz's Requests library. Today has been AWESOME.*8182**Kenny Meyers**—83 *Python HTTP: When in doubt, or when not in doubt, use Requests. Beautiful,84 simple, Pythonic.*8586Requests is one of the most downloaded Python packages of all time, pulling in84over 11,000,000 downloads every month. All the cool kids are doing it!87over 400,000 downloads **each day**. Join the party!8889If your organization uses Requests internally, consider `supporting the development of 3.0 <https://www.kennethreitz.org/requests3>`_. Your90generosity will be greatly appreciated, and help drive the project forward91into the future.9293Beloved Features94----------------9596Requests is ready for today's web.
13 unmodified lines
110- Connection Timeouts111- Chunked Requests112- ``.netrc`` Support113107Requests officially supports Python 2.6–2.7 & 3.3–3.7, and runs great on PyPy.114Requests officially supports Python 2.7 & 3.4–3.7, and runs great on PyPy.115116117The User Guide118--------------
18 unmodified lines
137This part of the documentation, which is mostly prose, details the138Requests ecosystem and community.139140.. toctree::134 :maxdepth: 1141 :maxdepth: 2142136 community/faq143 community/sponsors144 community/recommended145 community/faq146 community/out-there147 community/support148 community/vulnerabilities149 community/updates
30 unmodified lines
modified:requests/__init__.py+20 added-10 removed
20 unmodified lines
2122... or POST:2324 >>> payload = dict(key1='value1', key2='value2')25 >>> r = requests.post('http://httpbin.org/post', data=payload)25 >>> r = requests.post('https://httpbin.org/post', data=payload)26 >>> print(r.text)27 {28 ...29 "form": {
26 unmodified lines
5657 # Check urllib3 for compatibility.58 major, minor, patch = urllib3_version # noqa: F81159 major, minor, patch = int(major), int(minor), int(patch)60 # urllib3 >= 1.21.1, <= 1.2260 # urllib3 >= 1.21.1, <= 1.2461 assert major == 162 assert minor >= 2163 assert minor <= 2263 assert minor <= 246465 # Check chardet for compatibility.66 major, minor, patch = chardet_version.split('.')[:3]67 major, minor, patch = int(major), int(minor), int(patch)
2 unmodified lines
70 assert minor < 171 assert patch >= 2727374def _check_cryptography(cryptography_version):75 # cryptography < 1.3.476 try:77 cryptography_version = list(map(int, cryptography_version.split('.')))78 except ValueError:79 return8081 if cryptography_version < [1, 3, 4]:82 warning = 'Old version of cryptography ({}) may cause slowdown.'.format(cryptography_version)83 warnings.warn(warning, RequestsDependencyWarning)8485# Check imported dependencies for compatibility.86try:87 check_compatibility(urllib3.__version__, chardet.__version__)88except (AssertionError, ValueError):78 warnings.warn("urllib3 ({0}) or chardet ({1}) doesn't match a supported "89 warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "90 "version!".format(urllib3.__version__, chardet.__version__),91 RequestsDependencyWarning)9293# Attempt to enable urllib3's SNI support, if possible94try:95 from urllib3.contrib import pyopenssl96 pyopenssl.inject_into_urllib3()9798 # Check cryptography version99 from cryptography import __version__ as cryptography_version100 _check_cryptography(cryptography_version)101except ImportError:102 pass103104# urllib3's DependencyWarnings should be silenced.
17 unmodified lines
122)123124# Set default logging handler to avoid "No handler found" warnings.125import logging111try: # Python 2.7+112 from logging import NullHandler126from logging import NullHandler113except ImportError:114 class NullHandler(logging.Handler):115 def emit(self, record):116 pass127128logging.getLogger(__name__).addHandler(NullHandler())129130# FileModeWarnings go off per the default.
1 unmodified line
modified:requests/__version__.py+3 added-3 removed
3 unmodified lines
45__title__ = 'requests'6__description__ = 'Python HTTP for Humans.'7__url__ = 'http://python-requests.org'8__version__ = '2.18.3'9__build__ = 0x0218038__version__ = '2.20.0'9__build__ = 0x02200010__author__ = 'Kenneth Reitz'11__author_email__ = 'me@kennethreitz.org'12__license__ = 'Apache 2.0'13__copyright__ = 'Copyright 2017 Kenneth Reitz'13__copyright__ = 'Copyright 2018 Kenneth Reitz'14__cake__ = u'\u2728 \U0001f370 \u2728'
modified:requests/adapters.py+25 added-17 removed
11 unmodified lines
12import socket1314from urllib3.poolmanager import PoolManager, proxy_from_url15from urllib3.response import HTTPResponse16from urllib3.util import parse_url17from urllib3.util import Timeout as TimeoutSauce18from urllib3.util.retry import Retry19from urllib3.exceptions import ClosedPoolError20from urllib3.exceptions import ConnectTimeoutError
4 unmodified lines
25from urllib3.exceptions import ProtocolError26from urllib3.exceptions import ReadTimeoutError27from urllib3.exceptions import SSLError as _SSLError28from urllib3.exceptions import ResponseError29from urllib3.exceptions import LocationValueError3031from .models import Response32from .compat import urlparse, basestring31from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,32 prepend_scheme_if_needed, get_auth_from_url, urldefragauth,33 select_proxy)33from .utils import (DEFAULT_CA_BUNDLE_PATH, extract_zipped_paths,34 get_encoding_from_headers, prepend_scheme_if_needed,35 get_auth_from_url, urldefragauth, select_proxy)36from .structures import CaseInsensitiveDict37from .cookies import extract_cookies_to_jar38from .exceptions import (ConnectionError, ConnectTimeout, ReadTimeout, SSLError,37 ProxyError, RetryError, InvalidSchema)39 ProxyError, RetryError, InvalidSchema, InvalidProxyURL,40 InvalidURL)41from .auth import _basic_auth_str4243try:44 from urllib3.contrib.socks import SOCKSProxyManager
83 unmodified lines
128129 self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)130131 def __getstate__(self):129 return dict((attr, getattr(self, attr, None)) for attr in130 self.__attrs__)132 return {attr: getattr(self, attr, None) for attr in self.__attrs__}133134 def __setstate__(self, state):135 # Can't handle by adding 'proxy_manager' to self.__attrs__ because136 # self.poolmanager uses a lambda function, which isn't pickleable.
83 unmodified lines
220 if verify is not True:221 cert_loc = verify222223 if not cert_loc:222 cert_loc = DEFAULT_CA_BUNDLE_PATH224 cert_loc = extract_zipped_paths(DEFAULT_CA_BUNDLE_PATH)225226 if not cert_loc or not os.path.exists(cert_loc):227 raise IOError("Could not find a suitable TLS CA certificate bundle, "226 "invalid path: {0}".format(cert_loc))228 "invalid path: {}".format(cert_loc))229230 conn.cert_reqs = 'CERT_REQUIRED'231232 if not os.path.isdir(cert_loc):
13 unmodified lines
246 conn.cert_file = cert247 conn.key_file = None248 if conn.cert_file and not os.path.exists(conn.cert_file):249 raise IOError("Could not find the TLS certificate file, "248 "invalid path: {0}".format(conn.cert_file))250 "invalid path: {}".format(conn.cert_file))251 if conn.key_file and not os.path.exists(conn.key_file):252 raise IOError("Could not find the TLS key file, "251 "invalid path: {0}".format(conn.key_file))253 "invalid path: {}".format(conn.key_file))254255 def build_response(self, req, resp):256 """Builds a :class:`Response <requests.Response>` object from a urllib3257 response. This should not be called from user code, and is only exposed
43 unmodified lines
301 proxy = select_proxy(url, proxies)302303 if proxy:304 proxy = prepend_scheme_if_needed(proxy, 'http')305 proxy_url = parse_url(proxy)306 if not proxy_url.host:307 raise InvalidProxyURL("Please check proxy URL. It is malformed"308 " and could be missing the host.")309 proxy_manager = self.proxy_manager_for(proxy)310 conn = proxy_manager.connection_from_url(url)311 else:312 # Only scheme should be lower case
65 unmodified lines
378 This should not be called from user code, and is only exposed for use379 when subclassing the380 :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.381376 :param proxies: The url of the proxy being used for this request.382 :param proxy: The url of the proxy being used for this request.383 :rtype: dict384 """385 headers = {}386 username, password = get_auth_from_url(proxy)
20 unmodified lines
407 :param proxies: (optional) The proxies dictionary to apply to the request.408 :rtype: requests.Response409 """410411 try:405 conn = self.get_connection(request.url, proxies)412 conn = self.get_connection(request.url, proxies)413 except LocationValueError as e:414 raise InvalidURL(e, request=request)415416 self.cert_verify(conn, request.url, verify, cert)417 url = self.request_url(request, proxies)409 self.add_headers(request)418 self.add_headers(request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)419420 chunked = not (request.body is None or 'Content-Length' in request.headers)421422 if isinstance(timeout, tuple):
1 unmodified line
424 connect, read = timeout425 timeout = TimeoutSauce(connect=connect, read=read)426 except ValueError as e:427 # this may raise a string formatting error.419 err = ("Invalid timeout {0}. Pass a (connect, read) "428 err = ("Invalid timeout {}. Pass a (connect, read) "429 "timeout tuple, or a single float to set "430 "both timeouts to the same value".format(timeout))431 raise ValueError(err)432 elif isinstance(timeout, TimeoutSauce):
41 unmodified lines
474 low_conn.send(b'0\r\n\r\n')475476 # Receive the response from the server477 try:469 # For Python 2.7+ versions, use buffering of HTTP470 # responses478 # For Python 2.7, use buffering of HTTP responses479 r = low_conn.getresponse(buffering=True)480 except TypeError:473 # For compatibility with Python 2.6 versions and back481 # For compatibility with Python 3.3+482 r = low_conn.getresponse()483484 resp = HTTPResponse.from_httplib(485 r,
48 unmodified lines
modified:requests/api.py+14 added-8 removed
16 unmodified lines
17 """Constructs and sends a :class:`Request <Request>`.1819 :param method: method for the new :class:`Request` object.20 :param url: URL for the new :class:`Request` object.21 :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.22 :param data: (optional) Dictionary or list of tuples ``[(key, value)]`` (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`.23 :param json: (optional) json data to send in the body of the :class:`Request`.21 :param params: (optional) Dictionary, list of tuples or bytes to send22 in the body of the :class:`Request`.23 :param data: (optional) Dictionary, list of tuples, bytes, or file-like24 object to send in the body of the :class:`Request`.25 :param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.26 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.27 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.28 :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.29 ``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
18 unmodified lines
4849 Usage::5051 >>> import requests50 >>> req = requests.request('GET', 'http://httpbin.org/get')52 >>> req = requests.request('GET', 'https://httpbin.org/get')53 <Response [200]>54 """5556 # By using the 'with' statement we are sure the session is closed, thus we
6 unmodified lines
63def get(url, params=None, **kwargs):64 r"""Sends a GET request.6566 :param url: URL for the new :class:`Request` object.65 :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.67 :param params: (optional) Dictionary, list of tuples or bytes to send68 in the body of the :class:`Request`.69 :param \*\*kwargs: Optional arguments that ``request`` takes.70 :return: :class:`Response <Response>` object71 :rtype: requests.Response72 """
31 unmodified lines
104def post(url, data=None, json=None, **kwargs):105 r"""Sends a POST request.106107 :param url: URL for the new :class:`Request` object.105 :param data: (optional) Dictionary (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`.108 :param data: (optional) Dictionary, list of tuples, bytes, or file-like109 object to send in the body of the :class:`Request`.110 :param json: (optional) json data to send in the body of the :class:`Request`.111 :param \*\*kwargs: Optional arguments that ``request`` takes.112 :return: :class:`Response <Response>` object113 :rtype: requests.Response
5 unmodified lines
119def put(url, data=None, **kwargs):120 r"""Sends a PUT request.121122 :param url: URL for the new :class:`Request` object.119 :param data: (optional) Dictionary (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`.123 :param data: (optional) Dictionary, list of tuples, bytes, or file-like124 object to send in the body of the :class:`Request`.125 :param json: (optional) json data to send in the body of the :class:`Request`.126 :param \*\*kwargs: Optional arguments that ``request`` takes.127 :return: :class:`Response <Response>` object128 :rtype: requests.Response
5 unmodified lines
134def patch(url, data=None, **kwargs):135 r"""Sends a PATCH request.136137 :param url: URL for the new :class:`Request` object.133 :param data: (optional) Dictionary (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`.138 :param data: (optional) Dictionary, list of tuples, bytes, or file-like139 object to send in the body of the :class:`Request`.140 :param json: (optional) json data to send in the body of the :class:`Request`.141 :param \*\*kwargs: Optional arguments that ``request`` takes.142 :return: :class:`Response <Response>` object143 :rtype: requests.Response
15 unmodified lines
modified:requests/auth.py+14 added-2 removed
36 unmodified lines
37 # for things like ints. This will be removed in 3.0.0.38 if not isinstance(username, basestring):39 warnings.warn(40 "Non-string usernames will no longer be supported in Requests "41 "3.0.0. Please convert the object you've passed in ({0!r}) to "41 "3.0.0. Please convert the object you've passed in ({!r}) to "42 "a string or bytes object in the near future to avoid "43 "problems.".format(username),44 category=DeprecationWarning,45 )
1 unmodified line
4748 if not isinstance(password, basestring):49 warnings.warn(50 "Non-string passwords will no longer be supported in Requests "51 "3.0.0. Please convert the object you've passed in ({0!r}) to "51 "3.0.0. Please convert the object you've passed in ({!r}) to "52 "a string or bytes object in the near future to avoid "53 "problems.".format(password),54 category=DeprecationWarning,55 )
96 unmodified lines
152 if isinstance(x, str):153 x = x.encode('utf-8')154 return hashlib.sha1(x).hexdigest()155 hash_utf8 = sha_utf8156 elif _algorithm == 'SHA-256':157 def sha256_utf8(x):158 if isinstance(x, str):159 x = x.encode('utf-8')160 return hashlib.sha256(x).hexdigest()161 hash_utf8 = sha256_utf8162 elif _algorithm == 'SHA-512':163 def sha512_utf8(x):164 if isinstance(x, str):165 x = x.encode('utf-8')166 return hashlib.sha512(x).hexdigest()167 hash_utf8 = sha512_utf8168169 KD = lambda s, d: hash_utf8("%s:%s" % (s, d))170171 if hash_utf8 is None:
134 unmodified lines
modified:requests/compat.py+2 added-1 removed
41 unmodified lines
42 from urllib2 import parse_http_list43 import cookielib44 from Cookie import Morsel45 from StringIO import StringIO46 from collections import Callable, Mapping, MutableMapping, OrderedDict4747 from urllib3.packages.ordered_dict import OrderedDict4849 builtin_str = str50 bytes = str51 str = unicode
7 unmodified lines
59 from http import cookiejar as cookielib60 from http.cookies import Morsel61 from io import StringIO62 from collections import OrderedDict63 from collections.abc import Callable, Mapping, MutableMapping6465 builtin_str = str66 str = str67 bytes = bytes
3 unmodified lines
modified:requests/cookies.py+24 added-17 removed
10 unmodified lines
1112import copy13import time14import calendar15import collections1516from ._internal_utils import to_native_string18from .compat import cookielib, urlparse, urlunparse, Morsel17from .compat import cookielib, urlparse, urlunparse, Morsel, MutableMapping1819try:20 import threading21except ImportError:
145 unmodified lines
167 Use .get and .set and include domain and path args in order to be more specific.168 """169170172class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):171class RequestsCookieJar(cookielib.CookieJar, MutableMapping):172 """Compatibility class; is a cookielib.CookieJar, but exposes a dict173 interface.174175 This is the CookieJar we create by default for requests and sessions that
237 unmodified lines
413414 def copy(self):415 """Return a copy of this RequestsCookieJar."""416 new_cj = RequestsCookieJar()417 new_cj.set_policy(self.get_policy())418 new_cj.update(self)419 return new_cj420421 def get_policy(self):422 """Return the CookiePolicy instance used."""423 return self._policy424425426def _copy_cookie_jar(jar):427 if jar is None:428 return None429
13 unmodified lines
443444 By default, the pair of `name` and `value` will be set for the domain ''445 and sent on every request (this is sometimes called a "supercookie").446 """443 result = dict(444 version=0,445 name=name,446 value=value,447 port=None,448 domain='',449 path='/',450 secure=False,451 expires=None,452 discard=True,453 comment=None,454 comment_url=None,455 rest={'HttpOnly': None},456 rfc2109=False,)447 result = {448 'version': 0,449 'name': name,450 'value': value,451 'port': None,452 'domain': '',453 'path': '/',454 'secure': False,455 'expires': None,456 'discard': True,457 'comment': None,458 'comment_url': None,459 'rest': {'HttpOnly': None},460 'rfc2109': False,461 }462463 badargs = set(kwargs) - set(result)464 if badargs:465 err = 'create_cookie() got unexpected keyword arguments: %s'
45 unmodified lines
511 :param cookie_dict: Dict of key/values to insert into CookieJar.512 :param cookiejar: (optional) A cookiejar to add the cookies to.513 :param overwrite: (optional) If False, will not replace cookies514 already in the jar with new ones.515 :rtype: CookieJar516 """517 if cookiejar is None:518 cookiejar = RequestsCookieJar()519
10 unmodified lines
530 """Add cookies to cookiejar and returns a merged CookieJar.531532 :param cookiejar: CookieJar object to add the cookies to.533 :param cookies: Dictionary or CookieJar object to be added.534 :rtype: CookieJar535 """536 if not isinstance(cookiejar, cookielib.CookieJar):537 raise ValueError('You can only merge into CookieJar')538
11 unmodified lines
modified:requests/exceptions.py+4 added
83 unmodified lines
84class InvalidHeader(RequestException, ValueError):85 """The header value provided was somehow invalid."""868788class InvalidProxyURL(InvalidURL):89 """The proxy URL provided is invalid."""909192class ChunkedEncodingError(RequestException):93 """The server declared chunked encoding but sent an invalid chunk."""9495
31 unmodified lines
modified:requests/help.py+2 added-3 removed
11 unmodified lines
1213from . import __version__ as requests_version1415try:16 from .packages.urllib3.contrib import pyopenssl16 from urllib3.contrib import pyopenssl17except ImportError:18 pyopenssl = None19 OpenSSL = None20 cryptography = None
67 unmodified lines
88 idna_info = {89 'version': getattr(idna, '__version__', ''),90 }9192 # OPENSSL_VERSION_NUMBER doesn't exist in the Python 2.6 ssl module.93 system_ssl = getattr(ssl, 'OPENSSL_VERSION_NUMBER', None)92 system_ssl = ssl.OPENSSL_VERSION_NUMBER93 system_ssl_info = {94 'version': '%x' % system_ssl if system_ssl is not None else ''95 }96
23 unmodified lines
modified:requests/hooks.py+2 added-2 removed
13 unmodified lines
14HOOKS = ['response']151617def default_hooks():18 return dict((event, []) for event in HOOKS)18 return {event: [] for event in HOOKS}1920# TODO: response is the only one212223def dispatch_hook(key, hooks, hook_data, **kwargs):24 """Dispatches a hook dictionary on a given piece of data."""25 hooks = hooks or dict()25 hooks = hooks or {}26 hooks = hooks.get(key)27 if hooks:28 if hasattr(hooks, '__call__'):29 hooks = [hooks]
5 unmodified lines
modified:requests/models.py+21 added-16 removed
5 unmodified lines
67This module contains the primary objects that power Requests.8"""910import collections10import datetime11import sys1213# Import encoding now, to avoid implicit import later.
21 unmodified lines
35 guess_filename, get_auth_from_url, requote_uri,36 stream_decode_response_unicode, to_key_val_list, parse_header_links,37 iter_slices, guess_json_utf, super_len, check_header_validity)38from .compat import (39 Callable, Mapping,40 cookielib, urlunparse, urlsplit, urlencode, str, bytes,41 is_py2, chardet, builtin_str, basestring)42from .compat import json as complexjson43from .status_codes import codes
110 unmodified lines
154 fp = v155156 if isinstance(fp, (str, bytes, bytearray)):157 fdata = fp158 else:158 elif hasattr(fp, 'read'):159 fdata = fp.read()160 elif fp is None:161 continue162 else:163 fdata = fp164165 rf = RequestField(name=k, data=fdata, filename=fn, headers=fh)166 rf.make_multipart(content_type=ft)167 new_fields.append(rf)
9 unmodified lines
177178 if event not in self.hooks:179 raise ValueError('Unsupported event specified, with event name "%s"' % (event))180177 if isinstance(hook, collections.Callable):181 if isinstance(hook, Callable):182 self.hooks[event].append(hook)183 elif hasattr(hook, '__iter__'):180 self.hooks[event].extend(h for h in hook if isinstance(h, collections.Callable))184 self.hooks[event].extend(h for h in hook if isinstance(h, Callable))185186 def deregister_hook(self, event, hook):187 """Deregister a previously registered hook.188 Returns True if the hook existed, False if not.
14 unmodified lines
203 :param method: HTTP method to use.204 :param url: URL to send.205 :param headers: dictionary of headers to send.206 :param files: dictionary of {filename: fileobject} files to multipart upload.203 :param data: the body to attach to the request. If a dictionary is provided, form-encoding will take place.207 :param data: the body to attach to the request. If a dictionary or208 list of tuples ``[(key, value)]`` is provided, form-encoding will209 take place.210 :param json: json for the body to attach to the request (if files or data is not specified).205 :param params: dictionary of URL parameters to append to the URL.211 :param params: URL parameters to append to the URL. If a dictionary or212 list of tuples ``[(key, value)]`` is provided, form-encoding will213 take place.214 :param auth: Auth handler or (user, pass) tuple.215 :param cookies: dictionary or CookieJar of cookies to attach to this request.216 :param hooks: dictionary of callback hooks, for internal usage.217218 Usage::219220 >>> import requests213 >>> req = requests.Request('GET', 'http://httpbin.org/get')221 >>> req = requests.Request('GET', 'https://httpbin.org/get')222 >>> req.prepare()223 <PreparedRequest [GET]>224 """225
51 unmodified lines
277278 Usage::279280 >>> import requests273 >>> req = requests.Request('GET', 'http://httpbin.org/get')281 >>> req = requests.Request('GET', 'https://httpbin.org/get')282 >>> r = req.prepare()283 <PreparedRequest [GET]>284285 >>> s = requests.Session()
182 unmodified lines
468 body = body.encode('utf-8')469470 is_stream = all([471 hasattr(data, '__iter__'),464 not isinstance(data, (basestring, list, tuple, collections.Mapping))472 not isinstance(data, (basestring, list, tuple, Mapping))473 ])474475 try:476 length = super_len(data)
174 unmodified lines
651 # sure the content has been fully read.652 if not self._content_consumed:653 self.content654647 return dict(648 (attr, getattr(self, attr, None))649 for attr in self.__attrs__650 )655 return {attr: getattr(self, attr, None) for attr in self.__attrs__}656657 def __setstate__(self, state):658 for name, value in state.items():659 setattr(self, name, value)
30 unmodified lines
690 return self.iter_content(128)691692 @property693 def ok(self):689 """Returns True if :attr:`status_code` is less than 400.694 """Returns True if :attr:`status_code` is less than 400, False if not.695696 This attribute checks if the status code of the response is between697 400 and 600 to see if there was a client error or a server error. If693 the status code, is between 200 and 400, this will return True. This698 the status code is between 200 and 400, this will return True. This699 is **not** a check to see if the response code is ``200 OK``.700 """701 try:702 self.raise_for_status()
121 unmodified lines
824825 if self.status_code == 0 or self.raw is None:826 self._content = None827 else:823 self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()828 self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''829830 self._content_consumed = True831 # don't need to release the connection; that's been handled by urllib3832 # since we exhausted the data.
121 unmodified lines
modified:requests/sessions.py+47 added-23 removed
6 unmodified lines
7This module provides a Session object to manage and persist settings across8requests (cookies, auth, proxies).9"""10import os11import platform11import sys12import time13from collections import Mapping13from datetime import timedelta1415from .auth import _basic_auth_str17from .compat import cookielib, is_py3, OrderedDict, urljoin, urlparse16from .compat import cookielib, is_py3, OrderedDict, urljoin, urlparse, Mapping17from .cookies import (18 cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar, merge_cookies)19from .models import Request, PreparedRequest, DEFAULT_REDIRECT_LIMIT20from .hooks import default_hooks, dispatch_hook
15 unmodified lines
36# formerly defined here, reexposed here for backward compatibility37from .models import REDIRECT_STATI3839# Preferred clock, based on which one is more accurate on a given system.41if platform.system() == 'Windows':42 try: # Python 3.3+40if sys.platform == 'win32':41 try: # Python 3.4+42 preferred_clock = time.perf_counter43 except AttributeError: # Earlier than Python 3.44 preferred_clock = time.clock45else:
68 unmodified lines
114 location = location.encode('latin1')115 return to_native_string(location, 'utf8')116 return None117118 def should_strip_auth(self, old_url, new_url):119 """Decide whether Authorization header should be removed when redirecting"""120 old_parsed = urlparse(old_url)121 new_parsed = urlparse(new_url)122 if old_parsed.hostname != new_parsed.hostname:123 return True124 # Special case: allow http -> https redirect when using the standard125 # ports. This isn't specified by RFC 7235, but is kept to avoid126 # breaking backwards compatibility with older versions of requests127 # that allowed any redirects on the same host.128 if (old_parsed.scheme == 'http' and old_parsed.port in (80, None)129 and new_parsed.scheme == 'https' and new_parsed.port in (443, None)):130 return False131 # Standard case: root URI must match132 return old_parsed.port != new_parsed.port or old_parsed.scheme != new_parsed.scheme133134 def resolve_redirects(self, resp, req, stream=False, timeout=None,135 verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):136 """Receives a Response. Returns a generator of Responses or Requests."""137138 hist = [] # keep track of history139140 url = self.get_redirect_target(resp)141 previous_fragment = urlparse(req.url).fragment142 while url:143 prepared_request = req.copy()144145 # Update history and keep track of redirects.
16 unmodified lines
162 if url.startswith('//'):163 parsed_rurl = urlparse(resp.url)164 url = '%s:%s' % (to_native_string(parsed_rurl.scheme), url)165150 # The scheme should be lower case...166 # Normalize url case and attach previous fragment if needed (RFC 7231 7.1.2)167 parsed = urlparse(url)168 if parsed.fragment == '' and previous_fragment:169 parsed = parsed._replace(fragment=previous_fragment)170 elif parsed.fragment:171 previous_fragment = parsed.fragment172 url = parsed.geturl()173174 # Facilitate relative 'location' headers, as allowed by RFC 7231.175 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
75 unmodified lines
251 """252 headers = prepared_request.headers253 url = prepared_request.url254235 if 'Authorization' in headers:255 if 'Authorization' in headers and self.should_strip_auth(response.request.url, url):256 # If we get redirected to a new host, we should strip out any257 # authentication headers.238 original_parsed = urlparse(response.request.url)239 redirect_parsed = urlparse(url)258 del headers['Authorization']259241 if (original_parsed.hostname != redirect_parsed.hostname):242 del headers['Authorization']243260 # .netrc might have more auth for us on our new host.261 new_auth = get_netrc_auth(url) if self.trust_env else None262 if new_auth is not None:263 prepared_request.prepare_auth(new_auth)
46 unmodified lines
310 based on certain specs or browser behavior.311 """312 method = prepared_request.method313298 # http://tools.ietf.org/html/rfc7231#section-6.4.4314 # https://tools.ietf.org/html/rfc7231#section-6.4.4315 if response.status_code == codes.see_other and method != 'HEAD':316 method = 'GET'317318 # Do what the browsers do, despite standards...
17 unmodified lines
336 Basic Usage::337338 >>> import requests339 >>> s = requests.Session()324 >>> s.get('http://httpbin.org/get')340 >>> s.get('https://httpbin.org/get')341 <Response [200]>342343 Or as a context manager::344345 >>> with requests.Session() as s:330 >>> s.get('http://httpbin.org/get')346 >>> s.get('https://httpbin.org/get')347 <Response [200]>348 """349350 __attrs__ = [
113 unmodified lines
464 :param method: method for the new :class:`Request` object.465 :param url: URL for the new :class:`Request` object.466 :param params: (optional) Dictionary or bytes to be sent in the query467 string for the :class:`Request`.452 :param data: (optional) Dictionary, bytes, or file-like object to send453 in the body of the :class:`Request`.468 :param data: (optional) Dictionary, list of tuples, bytes, or file-like469 object to send in the body of the :class:`Request`.470 :param json: (optional) json to send in the body of the471 :class:`Request`.472 :param headers: (optional) Dictionary of HTTP Headers to send with the473 :class:`Request`.
87 unmodified lines
561 def post(self, url, data=None, json=None, **kwargs):562 r"""Sends a POST request. Returns :class:`Response` object.563564 :param url: URL for the new :class:`Request` object.549 :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.565 :param data: (optional) Dictionary, list of tuples, bytes, or file-like566 object to send in the body of the :class:`Request`.567 :param json: (optional) json to send in the body of the :class:`Request`.568 :param \*\*kwargs: Optional arguments that ``request`` takes.569 :rtype: requests.Response570 """
3 unmodified lines
574 def put(self, url, data=None, **kwargs):575 r"""Sends a PUT request. Returns :class:`Response` object.576577 :param url: URL for the new :class:`Request` object.561 :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.578 :param data: (optional) Dictionary, list of tuples, bytes, or file-like579 object to send in the body of the :class:`Request`.580 :param \*\*kwargs: Optional arguments that ``request`` takes.581 :rtype: requests.Response582 """583
2 unmodified lines
586 def patch(self, url, data=None, **kwargs):587 r"""Sends a PATCH request. Returns :class:`Response` object.588589 :param url: URL for the new :class:`Request` object.572 :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.590 :param data: (optional) Dictionary, list of tuples, bytes, or file-like591 object to send in the body of the :class:`Request`.592 :param \*\*kwargs: Optional arguments that ``request`` takes.593 :rtype: requests.Response594 """595
118 unmodified lines
714 :rtype: requests.adapters.BaseAdapter715 """716 for (prefix, adapter) in self.adapters.items():717699 if url.lower().startswith(prefix):718 if url.lower().startswith(prefix.lower()):719 return adapter720721 # Nothing matches :-/722 raise InvalidSchema("No connection adapters were found for '%s'" % url)
14 unmodified lines
737 for key in keys_to_move:738 self.adapters[key] = self.adapters.pop(key)739740 def __getstate__(self):722 state = dict((attr, getattr(self, attr, None)) for attr in self.__attrs__)741 state = {attr: getattr(self, attr, None) for attr in self.__attrs__}742 return state743744 def __setstate__(self, state):745 for attr, value in state.items():
3 unmodified lines
749def session():750 """751 Returns a :class:`Session` for context-management.752753 .. deprecated:: 1.0.0754755 This method has been deprecated since version 1.0.0 and is only kept for756 backwards compatibility. New code should use :class:`~requests.sessions.Session`757 to create a session. This may be removed at a future date.758759 :rtype: Session760 """736761 return Session()
modified:requests/status_codes.py+34 added-5 removed
1# -*- coding: utf-8 -*-23r"""4The ``codes`` object defines a mapping from common names for HTTP statuses5to their numerical codes, accessible either as attributes or as dictionary6items.78>>> requests.codes['temporary_redirect']930710>>> requests.codes.teapot1141812>>> requests.codes['\o/']132001415Some codes have multiple names, and both upper- and lower-case versions of16the names are allowed. For example, ``codes.ok``, ``codes.OK``, and17``codes.okay`` all correspond to the HTTP status code 200.18"""1920from .structures import LookupDict2122_codes = {23
76 unmodified lines
100}101102codes = LookupDict(name='status_codes')103104def _init():87for code, titles in _codes.items():88 for title in titles:89 setattr(codes, title, code)90 if not title.startswith(('\\', '/')):91 setattr(codes, title.upper(), code)105 for code, titles in _codes.items():106 for title in titles:107 setattr(codes, title, code)108 if not title.startswith(('\\', '/')):109 setattr(codes, title.upper(), code)110111 def doc(code):112 names = ', '.join('``%s``' % n for n in _codes[code])113 return '* %d: %s' % (code, names)114115 global __doc__116 __doc__ = (__doc__ + '\n' +117 '\n'.join(doc(code) for code in sorted(_codes))118 if __doc__ is not None else None)119120_init()
modified:requests/structures.py+4 added-6 removed
5 unmodified lines
67Data structures that power Requests.8"""910import collections10from .compat import OrderedDict, Mapping, MutableMapping1112from .compat import OrderedDict121415class CaseInsensitiveDict(collections.MutableMapping):13class CaseInsensitiveDict(MutableMapping):14 """A case-insensitive ``dict``-like object.1516 Implements all methods and operations of19 ``collections.MutableMapping`` as well as dict's ``copy``. Also17 ``MutableMapping`` as well as dict's ``copy``. Also18 provides ``lower_items``.1920 All keys are expected to be strings. The structure remembers the21 case of the last key to be set, and ``iter(instance)``,
46 unmodified lines
68 in self._store.items()69 )7071 def __eq__(self, other):74 if isinstance(other, collections.Mapping):72 if isinstance(other, Mapping):73 other = CaseInsensitiveDict(other)74 else:75 return NotImplemented76 # Compare insensitively
27 unmodified lines
modified:requests/utils.py+103 added-32 removed
6 unmodified lines
7This module provides utility functions that are used within Requests8that are also useful for external consumption.9"""1011import cgi11import codecs13import collections12import contextlib13import io14import os17import platform15import re16import socket17import struct18import sys19import tempfile20import warnings21import zipfile2223from .__version__ import __version__24from . import certs25# to_native_string is unused here, but imported here for backwards compatibility
1 unmodified line
27from .compat import parse_http_list as _parse_list_header28from .compat import (29 quote, urlparse, bytes, str, OrderedDict, unquote, getproxies,30 proxy_bypass, urlunparse, basestring, integer_types, is_py3,31 proxy_bypass_environment, getproxies_environment)31 proxy_bypass_environment, getproxies_environment, Mapping)32from .cookies import cookiejar_from_dict33from .structures import CaseInsensitiveDict34from .exceptions import (35 InvalidURL, InvalidHeader, FileModeWarning, UnrewindableBodyError)
2 unmodified lines
3839DEFAULT_CA_BUNDLE_PATH = certs.where()404142if platform.system() == 'Windows':42if sys.platform == 'win32':43 # provide a proxy_bypass version on Windows without DNS lookups4445 def proxy_bypass_registry(host):46 if is_py3:47 import winreg48 else:49 import _winreg as winreg46 try:47 if is_py3:48 import winreg49 else:50 import _winreg as winreg51 except ImportError:52 return False5354 try:55 internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,56 r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')57 # ProxyEnable could be REG_SZ or REG_DWORD, normalizing it53 proxyEnable = winreg.QueryValueEx(internetSettings,54 'ProxyEnable')[0]58 proxyEnable = int(winreg.QueryValueEx(internetSettings,59 'ProxyEnable')[0])60 # ProxyOverride is almost always a string61 proxyOverride = winreg.QueryValueEx(internetSettings,62 'ProxyOverride')[0]63 except OSError:64 return False
107 unmodified lines
172 netrc_path = None173174 for f in NETRC_FILES:175 try:170 loc = os.path.expanduser('~/{0}'.format(f))176 loc = os.path.expanduser('~/{}'.format(f))177 except KeyError:178 # os.path.expanduser can fail when $HOME is undefined and173 # getpwuid fails. See http://bugs.python.org/issue20164 &179 # getpwuid fails. See https://bugs.python.org/issue20164 &180 # https://github.com/requests/requests/issues/1846181 return182183 if os.path.exists(loc):
37 unmodified lines
221 name[-1] != '>'):222 return os.path.basename(name)223224225def extract_zipped_paths(path):226 """Replace nonexistent paths that look like they refer to a member of a zip227 archive with the location of an extracted copy of the target, or else228 just return the provided path unchanged.229 """230 if os.path.exists(path):231 # this is already a valid path, no need to do anything further232 return path233234 # find the first valid part of the provided path and treat that as a zip archive235 # assume the rest of the path is the name of a member in the archive236 archive, member = os.path.split(path)237 while archive and not os.path.exists(archive):238 archive, prefix = os.path.split(archive)239 member = '/'.join([prefix, member])240241 if not zipfile.is_zipfile(archive):242 return path243244 zip_file = zipfile.ZipFile(archive)245 if member not in zip_file.namelist():246 return path247248 # we have a valid zip archive and a valid member of that archive249 tmp = tempfile.gettempdir()250 extracted_path = os.path.join(tmp, *member.split('/'))251 if not os.path.exists(extracted_path):252 extracted_path = zip_file.extract(member, path=tmp)253254 return extracted_path255256257def from_key_val_list(value):258 """Take an object and test to see if it can be represented as a259 dictionary. Unless it can not be represented as such, return an260 OrderedDict, e.g.,
38 unmodified lines
299300 if isinstance(value, (str, bytes, bool, int)):301 raise ValueError('cannot encode objects that are not 2-tuples')302265 if isinstance(value, collections.Mapping):303 if isinstance(value, Mapping):304 value = value.items()305306 return list(value)307
136 unmodified lines
444 pragma_re.findall(content) +445 xml_re.findall(content))446447448def _parse_content_type_header(header):449 """Returns content type and parameters from given header450451 :param header: string452 :return: tuple containing content type and dictionary of453 parameters454 """455456 tokens = header.split(';')457 content_type, params = tokens[0].strip(), tokens[1:]458 params_dict = {}459 items_to_strip = "\"' "460461 for param in params:462 param = param.strip()463 if param:464 key, value = param, True465 index_of_equals = param.find("=")466 if index_of_equals != -1:467 key = param[:index_of_equals].strip(items_to_strip)468 value = param[index_of_equals + 1:].strip(items_to_strip)469 params_dict[key.lower()] = value470 return content_type, params_dict471472473def get_encoding_from_headers(headers):474 """Returns encodings from given HTTP Header Dict.475476 :param headers: dictionary to extract encoding from.
4 unmodified lines
481482 if not content_type:483 return None484422 content_type, params = cgi.parse_header(content_type)485 content_type, params = _parse_content_type_header(content_type)486487 if 'charset' in params:488 return params['charset'].strip("'\"")489
204 unmodified lines
694 Returns whether we should bypass proxies or not.695696 :rtype: bool697 """698 # Prioritize lowercase environment variables over uppercase699 # to keep a consistent behaviour with other http projects (curl, wget).700 get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper())701702 # First check whether no_proxy is defined. If it is, check that the URL703 # we're getting isn't in the no_proxy list.704 no_proxy_arg = no_proxy705 if no_proxy is None:706 no_proxy = get_proxy('no_proxy')642 netloc = urlparse(url).netloc707 parsed = urlparse(url)708709 if parsed.hostname is None:710 # URLs don't always have hostnames, e.g. file:/// urls.711 return True712713 if no_proxy:714 # We need to check whether we match here. We need to see if we match646 # the end of the netloc, both with and without the port.715 # the end of the hostname, both with and without the port.716 no_proxy = (717 host for host in no_proxy.replace(' ', '').split(',') if host718 )719651 ip = netloc.split(':')[0]652 if is_ipv4_address(ip):720 if is_ipv4_address(parsed.hostname):721 for proxy_ip in no_proxy:722 if is_valid_cidr(proxy_ip):655 if address_in_network(ip, proxy_ip):723 if address_in_network(parsed.hostname, proxy_ip):724 return True657 elif ip == proxy_ip:725 elif parsed.hostname == proxy_ip:726 # If no_proxy ip was defined in plain IP notation instead of cidr notation &727 # matches the IP of the index728 return True729 else:730 host_with_port = parsed.hostname731 if parsed.port:732 host_with_port += ':{}'.format(parsed.port)733734 for host in no_proxy:663 if netloc.endswith(host) or netloc.split(':')[0].endswith(host):735 if parsed.hostname.endswith(host) or host_with_port.endswith(host):736 # The URL does match something in no_proxy, so we don't want737 # to apply the proxies on this URL.738 return True739668 # If the system proxy settings indicate that this URL should be bypassed,669 # don't proxy.670 # The proxy_bypass function is incredibly buggy on OS X in early versions671 # of Python 2.6, so allow this call to fail. Only catch the specific672 # exceptions we've seen, though: this call failing in other ways can reveal673 # legitimate problems.740 with set_environ('no_proxy', no_proxy_arg):741 # parsed.hostname can be `None` in cases such as a file URI.742 try:676 bypass = proxy_bypass(netloc)743 bypass = proxy_bypass(parsed.hostname)744 except (TypeError, socket.gaierror):745 bypass = False746747 if bypass:
61 unmodified lines
809 })810811812def parse_header_links(value):746 """Return a dict of parsed link headers proxies.813 """Return a list of parsed link headers proxies.814815 i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"816817 :rtype: list
2 unmodified lines
820 links = []821822 replace_chars = ' \'"'823824 value = value.strip(replace_chars)825 if not value:826 return links827828 for val in re.split(', *<', value):829 try:830 url, params = val.split(';', 1)831 except ValueError:
106 unmodified lines
938 try:939 if not pat.match(value):940 raise InvalidHeader("Invalid return character or leading space in header: %s" % name)941 except TypeError:871 raise InvalidHeader("Header value %s must be of type str or bytes, "872 "not %s" % (value, type(value)))942 raise InvalidHeader("Value for header {%s: %s} must be of type str or "943 "bytes, not %s" % (name, value, type(value)))944945946def urldefragauth(url):947 """
28 unmodified lines
modified:tests/test_help.py-9 removed
5 unmodified lines
67from requests.help import info8910@pytest.mark.skipif(sys.version_info[:2] != (2,6), reason="Only run on Python 2.6")11def test_system_ssl_py26():12 """OPENSSL_VERSION_NUMBER isn't provided in Python 2.6, verify we don't13 blow up in this case.14 """15 assert info()['system_ssl'] == {'version': ''}161718@pytest.mark.skipif(sys.version_info < (2,7), reason="Only run on Python 2.7+")10def test_system_ssl():11 """Verify we're actually setting system_ssl when it should be available."""12 assert info()['system_ssl']['version'] != ''13
18 unmodified lines
modified:tests/test_lowlevel.py+82 added-10 removed
14 unmodified lines
15 server = Server.basic_response_server(wait_to_close_event=close_server)16 data = iter([b'a', b'b', b'c'])1718 with server as (host, port):19 url = 'http://{0}:{1}/'.format(host, port)19 url = 'http://{}:{}/'.format(host, port)20 r = requests.post(url, data=data, stream=True)21 close_server.set() # release server block2223 assert r.status_code == 200
52 unmodified lines
76 close_server = threading.Event()77 server = Server(digest_response_handler, wait_to_close_event=close_server)7879 with server as (host, port):80 url = 'http://{0}:{1}/'.format(host, port)80 url = 'http://{}:{}/'.format(host, port)81 r = requests.get(url, auth=auth)82 # Verify server succeeded in authenticating.83 assert r.status_code == 20084 # Verify Authorization was sent in final request.
41 unmodified lines
126 close_server = threading.Event()127 server = Server(digest_failed_response_handler, wait_to_close_event=close_server)128129 with server as (host, port):130 url = 'http://{0}:{1}/'.format(host, port)130 url = 'http://{}:{}/'.format(host, port)131 r = requests.get(url, auth=auth)132 # Verify server didn't authenticate us.133 assert r.status_code == 401134 assert r.history[0].status_code == 401
28 unmodified lines
163 close_server = threading.Event()164 server = Server(digest_response_handler, wait_to_close_event=close_server)165166 with server as (host, port):167 url = 'http://{0}:{1}/'.format(host, port)167 url = 'http://{}:{}/'.format(host, port)168 r = requests.get(url, auth=auth)169 # Verify server didn't receive auth from us.170 assert r.status_code == 200171 assert len(r.history) == 0
8 unmodified lines
180181_proxy_combos = []182for prefix, schemes in _schemes_by_var_prefix:183 for scheme in schemes:184 _proxy_combos.append(("{0}_proxy".format(prefix), scheme))184 _proxy_combos.append(("{}_proxy".format(prefix), scheme))185186_proxy_combos += [(var.upper(), scheme) for var, scheme in _proxy_combos]187188189@pytest.mark.parametrize("var,scheme", _proxy_combos)190def test_use_proxy_from_environment(httpbin, var, scheme):191 url = "{0}://httpbin.org".format(scheme)191 url = "{}://httpbin.org".format(scheme)192 fake_proxy = Server() # do nothing with the requests; just close the socket193 with fake_proxy as (host, port):194 proxy_url = "socks5://{0}:{1}".format(host, port)194 proxy_url = "socks5://{}:{}".format(host, port)195 kwargs = {var: proxy_url}196 with override_environ(**kwargs):197 # fake proxy's lack of response will cause a ConnectionError198 with pytest.raises(requests.exceptions.ConnectionError):
12 unmodified lines
211 redirect_request = [] # stores the second request to the server212213 def redirect_resp_handler(sock):214 consume_socket_content(sock, timeout=0.5)215 location = u'//{0}:{1}/{2}'.format(host, port, path)215 location = u'//{}:{}/{}'.format(host, port, path)216 sock.send(217 b'HTTP/1.1 301 Moved Permanently\r\n'218 b'Content-Length: 0\r\n'219 b'Location: ' + location.encode('utf8') + b'\r\n'
5 unmodified lines
225 close_server = threading.Event()226 server = Server(redirect_resp_handler, wait_to_close_event=close_server)227228 with server as (host, port):229 url = u'http://{0}:{1}'.format(host, port)229 url = u'http://{}:{}'.format(host, port)230 r = requests.get(url=url, allow_redirects=True)231 assert r.status_code == 200232 assert len(r.history) == 1233 assert r.history[0].status_code == 301234 assert redirect_request[0].startswith(b'GET /' + expected_path + b' HTTP/1.1')235 assert r.url == u'{0}/{1}'.format(url, expected_path.decode('ascii'))235 assert r.url == u'{}/{}'.format(url, expected_path.decode('ascii'))236237 close_server.set()238239def test_fragment_not_sent_with_request():240 """Verify that the fragment portion of a URI isn't sent to the server."""241 def response_handler(sock):242 req = consume_socket_content(sock, timeout=0.5)243 sock.send(244 b'HTTP/1.1 200 OK\r\n'245 b'Content-Length: '+bytes(len(req))+b'\r\n'246 b'\r\n'+req247 )248249 close_server = threading.Event()250 server = Server(response_handler, wait_to_close_event=close_server)251252 with server as (host, port):253 url = 'http://{}:{}/path/to/thing/#view=edit&token=hunter2'.format(host, port)254 r = requests.get(url)255 raw_request = r.content256257 assert r.status_code == 200258 headers, body = raw_request.split(b'\r\n\r\n', 1)259 status_line, headers = headers.split(b'\r\n', 1)260261 assert status_line == b'GET /path/to/thing/ HTTP/1.1'262 for frag in (b'view', b'edit', b'token', b'hunter2'):263 assert frag not in headers264 assert frag not in body265266 close_server.set()267268def test_fragment_update_on_redirect():269 """Verify we only append previous fragment if one doesn't exist on new270 location. If a new fragment is encountered in a Location header, it should271 be added to all subsequent requests.272 """273274 def response_handler(sock):275 consume_socket_content(sock, timeout=0.5)276 sock.send(277 b'HTTP/1.1 302 FOUND\r\n'278 b'Content-Length: 0\r\n'279 b'Location: /get#relevant-section\r\n\r\n'280 )281 consume_socket_content(sock, timeout=0.5)282 sock.send(283 b'HTTP/1.1 302 FOUND\r\n'284 b'Content-Length: 0\r\n'285 b'Location: /final-url/\r\n\r\n'286 )287 consume_socket_content(sock, timeout=0.5)288 sock.send(289 b'HTTP/1.1 200 OK\r\n\r\n'290 )291292 close_server = threading.Event()293 server = Server(response_handler, wait_to_close_event=close_server)294295 with server as (host, port):296 url = 'http://{}:{}/path/to/thing/#view=edit&token=hunter2'.format(host, port)297 r = requests.get(url)298 raw_request = r.content299300 assert r.status_code == 200301 assert len(r.history) == 2302 assert r.history[0].request.url == url303304 # Verify we haven't overwritten the location with our previous fragment.305 assert r.history[1].request.url == 'http://{}:{}/get#relevant-section'.format(host, port)306 # Verify previous fragment is used and not the original.307 assert r.url == 'http://{}:{}/final-url/#relevant-section'.format(host, port)308309 close_server.set()
modified:tests/test_requests.py+189 added-68 removed
21 unmodified lines
22 cookiejar_from_dict, morsel_to_cookie)23from requests.exceptions import (24 ConnectionError, ConnectTimeout, InvalidSchema, InvalidURL,25 MissingSchema, ReadTimeout, Timeout, RetryError, TooManyRedirects,26 ProxyError, InvalidHeader, UnrewindableBodyError, SSLError)26 ProxyError, InvalidHeader, UnrewindableBodyError, SSLError, InvalidProxyURL)27from requests.models import PreparedRequest28from requests.structures import CaseInsensitiveDict29from requests.sessions import SessionRedirectMixin30from requests.models import urlencode31from requests.hooks import default_hooks32from requests.compat import MutableMapping3334from .compat import StringIO, u35from .utils import override_environ36from urllib3.util import Timeout as Urllib3Timeout
17 unmodified lines
545556class TestRequests:5758 digest_auth_algo = ('MD5', 'SHA-256', 'SHA-512')5960 def test_entry_points(self):6162 requests.session63 requests.session().get
93 unmodified lines
157 parts = urlparse(httpbin('get'))158 url = scheme + parts.netloc + parts.path159 r = requests.Request('GET', url)160 r = s.send(r.prepare())158 assert r.status_code == 200, 'failed for scheme {0}'.format(scheme)161 assert r.status_code == 200, 'failed for scheme {}'.format(scheme)162163 def test_HTTP_200_OK_GET_ALTERNATIVE(self, httpbin):164 r = requests.Request('GET', httpbin('get'))165 s = requests.Session()
130 unmodified lines
296 assert next_resp.request.body is None297 for header in purged_headers:298 assert header not in next_resp.request.headers299300 def test_fragment_maintained_on_redirect(self, httpbin):301 fragment = "#view=edit&token=hunter2"302 r = requests.get(httpbin('redirect-to?url=get')+fragment)303304 assert len(r.history) > 0305 assert r.history[0].request.url == httpbin('redirect-to?url=get')+fragment306 assert r.url == httpbin('get')+fragment307308 def test_HTTP_200_OK_GET_WITH_PARAMS(self, httpbin):309 heads = {'User-agent': 'Mozilla/5.0'}310311 r = requests.get(httpbin('user-agent'), headers=heads)
224 unmodified lines
536 # any proxy related error (address resolution, no route to host, etc) should result in a ProxyError537 with pytest.raises(ProxyError):538 requests.get('http://localhost:1', proxies={'http': 'non-resolvable-address'})539540 def test_proxy_error_on_bad_url(self, httpbin, httpbin_secure):541 with pytest.raises(InvalidProxyURL):542 requests.get(httpbin_secure(), proxies={'https': 'http:/badproxyurl:3128'})543544 with pytest.raises(InvalidProxyURL):545 requests.get(httpbin(), proxies={'http': 'http://:8080'})546547 with pytest.raises(InvalidProxyURL):548 requests.get(httpbin_secure(), proxies={'https': 'https://'})549550 with pytest.raises(InvalidProxyURL):551 requests.get(httpbin(), proxies={'http': 'http:///example.com:8080'})552553 def test_basicauth_with_netrc(self, httpbin):554 auth = ('user', 'pass')555 wrong_auth = ('wronguser', 'wrongpass')556 url = httpbin('basic-auth', 'user', 'pass')
27 unmodified lines
584 requests.sessions.get_netrc_auth = old_auth585586 def test_DIGEST_HTTP_200_OK_GET(self, httpbin):587588 for authtype in self.digest_auth_algo:564 auth = HTTPDigestAuth('user', 'pass')565 url = httpbin('digest-auth', 'auth', 'user', 'pass')589 auth = HTTPDigestAuth('user', 'pass')590 url = httpbin('digest-auth', 'auth', 'user', 'pass', authtype, 'never')591567 r = requests.get(url, auth=auth)568 assert r.status_code == 200592 r = requests.get(url, auth=auth)593 assert r.status_code == 200594570 r = requests.get(url)571 assert r.status_code == 401595 r = requests.get(url)596 assert r.status_code == 401597 print(r.headers['WWW-Authenticate'])598573 s = requests.session()574 s.auth = HTTPDigestAuth('user', 'pass')575 r = s.get(url)576 assert r.status_code == 200599 s = requests.session()600 s.auth = HTTPDigestAuth('user', 'pass')601 r = s.get(url)602 assert r.status_code == 200603604 def test_DIGEST_AUTH_RETURNS_COOKIE(self, httpbin):579 url = httpbin('digest-auth', 'auth', 'user', 'pass')580 auth = HTTPDigestAuth('user', 'pass')581 r = requests.get(url)582 assert r.cookies['fake'] == 'fake_value'605584 r = requests.get(url, auth=auth)585 assert r.status_code == 200606 for authtype in self.digest_auth_algo:607 url = httpbin('digest-auth', 'auth', 'user', 'pass', authtype)608 auth = HTTPDigestAuth('user', 'pass')609 r = requests.get(url)610 assert r.cookies['fake'] == 'fake_value'611612 r = requests.get(url, auth=auth)613 assert r.status_code == 200614615 def test_DIGEST_AUTH_SETS_SESSION_COOKIES(self, httpbin):588 url = httpbin('digest-auth', 'auth', 'user', 'pass')589 auth = HTTPDigestAuth('user', 'pass')590 s = requests.Session()591 s.get(url, auth=auth)592 assert s.cookies['fake'] == 'fake_value'616617 for authtype in self.digest_auth_algo:618 url = httpbin('digest-auth', 'auth', 'user', 'pass', authtype)619 auth = HTTPDigestAuth('user', 'pass')620 s = requests.Session()621 s.get(url, auth=auth)622 assert s.cookies['fake'] == 'fake_value'623624 def test_DIGEST_STREAM(self, httpbin):625626 for authtype in self.digest_auth_algo:596 auth = HTTPDigestAuth('user', 'pass')597 url = httpbin('digest-auth', 'auth', 'user', 'pass')627 auth = HTTPDigestAuth('user', 'pass')628 url = httpbin('digest-auth', 'auth', 'user', 'pass', authtype)629599 r = requests.get(url, auth=auth, stream=True)600 assert r.raw.read() != b''630 r = requests.get(url, auth=auth, stream=True)631 assert r.raw.read() != b''632602 r = requests.get(url, auth=auth, stream=False)603 assert r.raw.read() == b''633 r = requests.get(url, auth=auth, stream=False)634 assert r.raw.read() == b''635636 def test_DIGESTAUTH_WRONG_HTTP_401_GET(self, httpbin):637638 for authtype in self.digest_auth_algo:607 auth = HTTPDigestAuth('user', 'wrongpass')608 url = httpbin('digest-auth', 'auth', 'user', 'pass')639 auth = HTTPDigestAuth('user', 'wrongpass')640 url = httpbin('digest-auth', 'auth', 'user', 'pass', authtype)641610 r = requests.get(url, auth=auth)611 assert r.status_code == 401642 r = requests.get(url, auth=auth)643 assert r.status_code == 401644613 r = requests.get(url)614 assert r.status_code == 401645 r = requests.get(url)646 assert r.status_code == 401647616 s = requests.session()617 s.auth = auth618 r = s.get(url)619 assert r.status_code == 401648 s = requests.session()649 s.auth = auth650 r = s.get(url)651 assert r.status_code == 401652653 def test_DIGESTAUTH_QUOTES_QOP_VALUE(self, httpbin):654655 for authtype in self.digest_auth_algo:623 auth = HTTPDigestAuth('user', 'pass')624 url = httpbin('digest-auth', 'auth', 'user', 'pass')656 auth = HTTPDigestAuth('user', 'pass')657 url = httpbin('digest-auth', 'auth', 'user', 'pass', authtype)658626 r = requests.get(url, auth=auth)627 assert '"auth"' in r.request.headers['Authorization']659 r = requests.get(url, auth=auth)660 assert '"auth"' in r.request.headers['Authorization']661662 def test_POSTBIN_GET_POST_FILES(self, httpbin):663664 url = httpbin('post')
1 unmodified line
666667 post1 = requests.post(url, data={'some': 'data'})668 assert post1.status_code == 200669637 with open('requirements.txt') as f:670 with open('Pipfile') as f:671 post2 = requests.post(url, files={'some': f})672 assert post2.status_code == 200673674 post4 = requests.post(url, data='[{"some": "json"}]')
1 unmodified line
676677 with pytest.raises(ValueError):678 requests.post(url, files=['bad file data'])679680 def test_invalid_files_input(self, httpbin):681682 url = httpbin('post')683 post = requests.post(url,684 files={"random-file-1": None, "random-file-2": 1})685 assert b'name="random-file-1"' not in post.request.body686 assert b'name="random-file-2"' in post.request.body687688 def test_POSTBIN_SEEKED_OBJECT_WITH_NO_ITER(self, httpbin):689690 class TestStream(object):691 def __init__(self, data):
42 unmodified lines
734735 post1 = requests.post(url, data={'some': 'data'})736 assert post1.status_code == 200737697 with open('requirements.txt') as f:738 with open('Pipfile') as f:739 post2 = requests.post(url, data={'some': 'data'}, files={'some': f})740 assert post2.status_code == 200741742 post4 = requests.post(url, data='[{"some": "json"}]')
2 unmodified lines
745 with pytest.raises(ValueError):746 requests.post(url, files=['bad file data'])747748 def test_post_with_custom_mapping(self, httpbin):708 class CustomMapping(collections.MutableMapping):749 class CustomMapping(MutableMapping):750 def __init__(self, *args, **kwargs):751 self.data = dict(*args, **kwargs)752753 def __delitem__(self, key):
17 unmodified lines
771 assert found_json == {'some': 'data'}772773 def test_conflicting_post_params(self, httpbin):774 url = httpbin('post')734 with open('requirements.txt') as f:775 with open('Pipfile') as f:776 pytest.raises(ValueError, "requests.post(url, data='[{\"some\": \"data\"}]', files={'some': f})")777 pytest.raises(ValueError, "requests.post(url, data=u('[{\"some\": \"data\"}]'), files={'some': f})")778779 def test_request_ok_set(self, httpbin):
35 unmodified lines
815 def test_invalid_ca_certificate_path(self, httpbin_secure):816 INVALID_PATH = '/garbage'817 with pytest.raises(IOError) as e:818 requests.get(httpbin_secure(), verify=INVALID_PATH)778 assert str(e.value) == 'Could not find a suitable TLS CA certificate bundle, invalid path: {0}'.format(INVALID_PATH)819 assert str(e.value) == 'Could not find a suitable TLS CA certificate bundle, invalid path: {}'.format(INVALID_PATH)820821 def test_invalid_ssl_certificate_files(self, httpbin_secure):822 INVALID_PATH = '/garbage'823 with pytest.raises(IOError) as e:824 requests.get(httpbin_secure(), cert=INVALID_PATH)784 assert str(e.value) == 'Could not find the TLS certificate file, invalid path: {0}'.format(INVALID_PATH)825 assert str(e.value) == 'Could not find the TLS certificate file, invalid path: {}'.format(INVALID_PATH)826827 with pytest.raises(IOError) as e:828 requests.get(httpbin_secure(), cert=('.', INVALID_PATH))788 assert str(e.value) == 'Could not find the TLS key file, invalid path: {0}'.format(INVALID_PATH)829 assert str(e.value) == 'Could not find the TLS key file, invalid path: {}'.format(INVALID_PATH)830831 def test_http_with_certificate(self, httpbin):832 r = requests.get(httpbin(), cert='.')833 assert r.status_code == 200
29 unmodified lines
863 requests.get(httpbin_secure('status', '200'))864865 def test_urlencoded_get_query_multivalued_param(self, httpbin):866826 r = requests.get(httpbin('get'), params=dict(test=['foo', 'baz']))867 r = requests.get(httpbin('get'), params={'test': ['foo', 'baz']})868 assert r.status_code == 200869 assert r.url == httpbin('get?test=foo&test=baz')870871 def test_form_encoded_post_query_multivalued_element(self, httpbin):872 r = requests.Request(method='POST', url=httpbin('post'),873 data=dict(test=['foo', 'baz']))874 prep = r.prepare()875 assert prep.body == 'test=foo&test=baz'876877 def test_different_encodings_dont_break_post(self, httpbin):878 r = requests.post(httpbin('post'),879 data={'stuff': json.dumps({'a': 123})},880 params={'blah': 'asdf1234'},
296 unmodified lines
1177 jar.set(key, value)1178 with pytest.raises(requests.cookies.CookieConflictError):1179 jar.get(key)11801181 def test_cookie_policy_copy(self):1182 class MyCookiePolicy(cookielib.DefaultCookiePolicy):1183 pass11841185 jar = requests.cookies.RequestsCookieJar()1186 jar.set_policy(MyCookiePolicy())1187 assert isinstance(jar.copy().get_policy(), MyCookiePolicy)11881189 def test_time_elapsed_blank(self, httpbin):1190 r = requests.get(httpbin('get'))1191 td = r.elapsed1192 total_seconds = ((td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6)
212 unmodified lines
1405 s2.mount('https://', HTTPAdapter())1406 assert 'http://' in s2.adapters1407 assert 'https://' in s2.adapters14081409 def test_session_get_adapter_prefix_matching(self):1410 prefix = 'https://example.com'1411 more_specific_prefix = prefix + '/some/path'14121413 url_matching_only_prefix = prefix + '/another/path'1414 url_matching_more_specific_prefix = more_specific_prefix + '/longer/path'1415 url_not_matching_prefix = 'https://another.example.com/'14161417 s = requests.Session()1418 prefix_adapter = HTTPAdapter()1419 more_specific_prefix_adapter = HTTPAdapter()1420 s.mount(prefix, prefix_adapter)1421 s.mount(more_specific_prefix, more_specific_prefix_adapter)14221423 assert s.get_adapter(url_matching_only_prefix) is prefix_adapter1424 assert s.get_adapter(url_matching_more_specific_prefix) is more_specific_prefix_adapter1425 assert s.get_adapter(url_not_matching_prefix) not in (prefix_adapter, more_specific_prefix_adapter)14261427 def test_session_get_adapter_prefix_matching_mixed_case(self):1428 mixed_case_prefix = 'hTtPs://eXamPle.CoM/MixEd_CAse_PREfix'1429 url_matching_prefix = mixed_case_prefix + '/full_url'14301431 s = requests.Session()1432 my_adapter = HTTPAdapter()1433 s.mount(mixed_case_prefix, my_adapter)14341435 assert s.get_adapter(url_matching_prefix) is my_adapter14361437 def test_session_get_adapter_prefix_matching_is_case_insensitive(self):1438 mixed_case_prefix = 'hTtPs://eXamPle.CoM/MixEd_CAse_PREfix'1439 url_matching_prefix_with_different_case = 'HtTpS://exaMPLe.cOm/MiXeD_caSE_preFIX/another_url'14401441 s = requests.Session()1442 my_adapter = HTTPAdapter()1443 s.mount(mixed_case_prefix, my_adapter)14441445 assert s.get_adapter(url_matching_prefix_with_different_case) is my_adapter14461447 def test_header_remove_is_case_insensitive(self, httpbin):1448 # From issue #13211449 s = requests.Session()1450 s.headers['foo'] = 'bar'
6 unmodified lines
1457 r = s.get(httpbin('get'), params={'FOO': 'bar'})1458 assert r.json()['args'] == {'foo': 'bar', 'FOO': 'bar'}14591460 def test_long_authinfo_in_url(self):1368 url = 'http://{0}:{1}@{2}:9000/path?query#frag'.format(1461 url = 'http://{}:{}@{}:9000/path?query#frag'.format(1462 'E8A3BE87-9E3F-4620-8858-95478E385B5B',1463 'EA770032-DA4D-4D84-8CE9-29C6D910BF1E',1464 'exactly-------------sixty-----------three------------characters',1465 )
27 unmodified lines
1493 headers_dict = {'bar': {'foo': 'bar'}}1494 headers_list = {'baz': ['foo', 'bar']}14951496 # Test for int1404 with pytest.raises(InvalidHeader):1497 with pytest.raises(InvalidHeader) as excinfo:1498 r = requests.get(httpbin('get'), headers=headers_int)1499 assert 'foo' in str(excinfo.value)1500 # Test for dict1407 with pytest.raises(InvalidHeader):1501 with pytest.raises(InvalidHeader) as excinfo:1502 r = requests.get(httpbin('get'), headers=headers_dict)1503 assert 'bar' in str(excinfo.value)1504 # Test for list1410 with pytest.raises(InvalidHeader):1505 with pytest.raises(InvalidHeader) as excinfo:1506 r = requests.get(httpbin('get'), headers=headers_list)1507 assert 'baz' in str(excinfo.value)15081509 def test_header_no_return_chars(self, httpbin):1510 """Ensure that a header containing return character sequences raise an1511 exception. Otherwise, multiple headers are created from single string.
60 unmodified lines
1572 req = requests.Request('GET', test_url)1573 preq = req.prepare()1574 assert test_url == preq.url15751480 @pytest.mark.xfail(raises=ConnectionError)1481 def test_auth_is_stripped_on_redirect_off_host(self, httpbin):1576 def test_auth_is_stripped_on_http_downgrade(self, httpbin, httpbin_secure, httpbin_ca_bundle):1577 r = requests.get(1483 httpbin('redirect-to'),1484 params={'url': 'http://www.google.co.uk'},1578 httpbin_secure('redirect-to'),1579 params={'url': httpbin('get')},1580 auth=('user', 'pass'),1581 verify=httpbin_ca_bundle1582 )1583 assert r.history[0].request.headers['Authorization']1488 assert not r.request.headers.get('Authorization', '')1584 assert 'Authorization' not in r.request.headers15851586 def test_auth_is_retained_for_redirect_on_host(self, httpbin):1587 r = requests.get(httpbin('redirect/1'), auth=('user', 'pass'))1588 h1 = r.history[0].request.headers['Authorization']1589 h2 = r.request.headers['Authorization']15901591 assert h1 == h215921593 def test_should_strip_auth_host_change(self):1594 s = requests.Session()1595 assert s.should_strip_auth('http://example.com/foo', 'http://another.example.com/')15961597 def test_should_strip_auth_http_downgrade(self):1598 s = requests.Session()1599 assert s.should_strip_auth('https://example.com/foo', 'http://example.com/bar')16001601 def test_should_strip_auth_https_upgrade(self):1602 s = requests.Session()1603 assert not s.should_strip_auth('http://example.com/foo', 'https://example.com/bar')1604 assert not s.should_strip_auth('http://example.com:80/foo', 'https://example.com/bar')1605 assert not s.should_strip_auth('http://example.com/foo', 'https://example.com:443/bar')1606 # Non-standard ports should trigger stripping1607 assert s.should_strip_auth('http://example.com:8080/foo', 'https://example.com/bar')1608 assert s.should_strip_auth('http://example.com/foo', 'https://example.com:8443/bar')16091610 def test_should_strip_auth_port_change(self):1611 s = requests.Session()1612 assert s.should_strip_auth('http://example.com:1234/foo', 'https://example.com:4321/bar')16131614 def test_manual_redirect_with_partial_body_read(self, httpbin):1615 s = requests.Session()1616 r1 = s.get(httpbin('redirect/2'), allow_redirects=False, stream=True)1617 assert r1.is_redirect
13 unmodified lines
1631 assert not r3.is_redirect16321633 def test_prepare_body_position_non_stream(self):1634 data = b'the data'1518 s = requests.Session()1635 prep = requests.Request('GET', 'http://example.com', data=data).prepare()1636 assert prep._body_position is None16371638 def test_rewind_body(self):1639 data = io.BytesIO(b'the data')1524 s = requests.Session()1640 prep = requests.Request('GET', 'http://example.com', data=data).prepare()1641 assert prep._body_position == 01642 assert prep.body.read() == b'the data'1643
5 unmodified lines
1649 assert prep.body.read() == b'the data'16501651 def test_rewind_partially_read_body(self):1652 data = io.BytesIO(b'the data')1538 s = requests.Session()1653 data.read(4) # read some data1654 prep = requests.Request('GET', 'http://example.com', data=data).prepare()1655 assert prep._body_position == 41656 assert prep.body.read() == b'data'
16 unmodified lines
1673 def __iter__(self):1674 return16751676 data = BadFileObj('the data')1563 s = requests.Session()1677 prep = requests.Request('GET', 'http://example.com', data=data).prepare()1678 assert prep._body_position == 016791680 with pytest.raises(UnrewindableBodyError) as e:
15 unmodified lines
1696 def __iter__(self):1697 return16981699 data = BadFileObj('the data')1587 s = requests.Session()1700 prep = requests.Request('GET', 'http://example.com', data=data).prepare()1701 assert prep._body_position == 017021703 with pytest.raises(UnrewindableBodyError) as e:
12 unmodified lines
1716 def __iter__(self):1717 return17181719 data = BadFileObj('the data')1608 s = requests.Session()1720 prep = requests.Request('GET', 'http://example.com', data=data).prepare()1721 assert prep._body_position is not None17221723 with pytest.raises(UnrewindableBodyError) as e:
97 unmodified lines
1821 session.close()1822 proxies['one'].clear.assert_called_once_with()1823 proxies['two'].clear.assert_called_once_with()18241714 def test_proxy_auth(self, httpbin):1825 def test_proxy_auth(self):1826 adapter = HTTPAdapter()1827 headers = adapter.proxy_headers("http://user:pass@httpbin.org")1828 assert headers == {'Proxy-Authorization': 'Basic dXNlcjpwYXNz'}18291719 def test_proxy_auth_empty_pass(self, httpbin):1830 def test_proxy_auth_empty_pass(self):1831 adapter = HTTPAdapter()1832 headers = adapter.proxy_headers("http://user:@httpbin.org")1833 assert headers == {'Proxy-Authorization': 'Basic dXNlcjo='}1834
591 unmodified lines
2426 with pytest.raises(requests.exceptions.InvalidURL):2427 r.prepare()24282429 @pytest.mark.parametrize(2430 'url, exception',2431 (2432 ('http://localhost:-1', InvalidURL),2433 )2434 )2435 def test_redirecting_to_bad_url(self, httpbin, url, exception):2436 with pytest.raises(exception):2437 r = requests.get(httpbin('redirect-to'), params={'url': url})24382439 @pytest.mark.parametrize(2440 'input, expected',2441 (2442 (2443 b"http+unix://%2Fvar%2Frun%2Fsocket/path%7E",
64 unmodified lines
modified:tests/test_testserver.py+3 added-3 removed
48 unmodified lines
49 "\r\nroflol"50 )5152 with server as (host, port):53 r = requests.get('http://{0}:{1}'.format(host, port))53 r = requests.get('http://{}:{}'.format(host, port))5455 assert r.status_code == 20056 assert r.text == u'roflol'57 assert r.headers['Content-Length'] == '6'5859 def test_basic_response(self):60 """the basic response server returns an empty http response"""61 with Server.basic_response_server() as (host, port):62 r = requests.get('http://{0}:{1}'.format(host, port))62 r = requests.get('http://{}:{}'.format(host, port))63 assert r.status_code == 20064 assert r.text == u''65 assert r.headers['Content-Length'] == '0'66
15 unmodified lines
8283 server = Server.basic_response_server(requests_to_handle=requests_to_handle)8485 with server as (host, port):86 server_url = 'http://{0}:{1}'.format(host, port)86 server_url = 'http://{}:{}'.format(host, port)87 for _ in range(requests_to_handle):88 r = requests.get(server_url)89 assert r.status_code == 20090
76 unmodified lines
modified:tests/test_utils.py+108 added-6 removed
1# -*- coding: utf-8 -*-23import os4import copy5import filecmp6from io import BytesIO7import zipfile8from collections import deque910import pytest11from requests import compat12from requests.cookies import RequestsCookieJar13from requests.structures import CaseInsensitiveDict14from requests.utils import (12 address_in_network, dotted_netmask,13 get_auth_from_url, get_encoding_from_headers,15 address_in_network, dotted_netmask, extract_zipped_paths,16 get_auth_from_url, _parse_content_type_header, get_encoding_from_headers,17 get_encodings_from_content, get_environ_proxies,18 guess_filename, guess_json_utf, is_ipv4_address,19 is_valid_cidr, iter_slices, parse_dict_header,20 parse_header_links, prepend_scheme_if_needed,
237 unmodified lines
258 assert result == value259 assert isinstance(result, expected_type)260261262class TestExtractZippedPaths:263264 @pytest.mark.parametrize(265 'path', (266 '/',267 __file__,268 pytest.__file__,269 '/etc/invalid/location',270 ))271 def test_unzipped_paths_unchanged(self, path):272 assert path == extract_zipped_paths(path)273274 def test_zipped_paths_extracted(self, tmpdir):275 zipped_py = tmpdir.join('test.zip')276 with zipfile.ZipFile(zipped_py.strpath, 'w') as f:277 f.write(__file__)278279 _, name = os.path.splitdrive(__file__)280 zipped_path = os.path.join(zipped_py.strpath, name.lstrip(r'\/'))281 extracted_path = extract_zipped_paths(zipped_path)282283 assert extracted_path != zipped_path284 assert os.path.exists(extracted_path)285 assert filecmp.cmp(extracted_path, __file__)286287288class TestContentEncodingDetection:289290 def test_none(self):291 encodings = get_encodings_from_content('')
180 unmodified lines
472473@pytest.mark.parametrize(474 'value, expected', (475 (476 'application/xml',477 ('application/xml', {})478 ),479 (480 'application/json ; charset=utf-8',481 ('application/json', {'charset': 'utf-8'})482 ),483 (484 'application/json ; Charset=utf-8',485 ('application/json', {'charset': 'utf-8'})486 ),487 (488 'text/plain',489 ('text/plain', {})490 ),491 (492 'multipart/form-data; boundary = something ; boundary2=\'something_else\' ; no_equals ',493 ('multipart/form-data', {'boundary': 'something', 'boundary2': 'something_else', 'no_equals': True})494 ),495 (496 'multipart/form-data; boundary = something ; boundary2="something_else" ; no_equals ',497 ('multipart/form-data', {'boundary': 'something', 'boundary2': 'something_else', 'no_equals': True})498 ),499 (500 'multipart/form-data; boundary = something ; \'boundary2=something_else\' ; no_equals ',501 ('multipart/form-data', {'boundary': 'something', 'boundary2': 'something_else', 'no_equals': True})502 ),503 (504 'multipart/form-data; boundary = something ; "boundary2=something_else" ; no_equals ',505 ('multipart/form-data', {'boundary': 'something', 'boundary2': 'something_else', 'no_equals': True})506 ),507 (508 'application/json ; ; ',509 ('application/json', {})510 )511 ))512def test__parse_content_type_header(value, expected):513 assert _parse_content_type_header(value) == expected514515516@pytest.mark.parametrize(517 'value, expected', (518 (519 CaseInsensitiveDict(),520 None521 ),522 (
46 unmodified lines
569 {'url': 'http:/.../front.jpeg', 'type': 'image/jpeg'},570 {'url': 'http://.../back.jpeg'}571 ]572 ),573 (574 '',575 []576 ),577 ))578def test_parse_header_links(value, expected):579 assert parse_header_links(value) == expected580
36 unmodified lines
617 ('http://192.168.0.1/', True),618 ('http://172.16.1.1/', True),619 ('http://172.16.1.1:5000/', True),620 ('http://localhost.localdomain:5000/v1.0/', True),621 ('http://google.com:6000/', True),622 ('http://172.16.1.12/', False),623 ('http://172.16.1.12:5000/', False),624 ('http://google.com:5000/v1.0/', False),625 ('file:///some/path/on/disk', True),626 ))627def test_should_bypass_proxies(url, expected, monkeypatch):628 """Tests for function should_bypass_proxies to check if proxy629 can be bypassed or not630 """553 monkeypatch.setenv('no_proxy', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1')554 monkeypatch.setenv('NO_PROXY', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1')631 monkeypatch.setenv('no_proxy', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1, google.com:6000')632 monkeypatch.setenv('NO_PROXY', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1, google.com:6000')633 assert should_bypass_proxies(url, no_proxy=None) == expected634635636@pytest.mark.parametrize(637 'url, expected', (638 ('http://172.16.1.1/', '172.16.1.1'),639 ('http://172.16.1.1:5000/', '172.16.1.1'),640 ('http://user:pass@172.16.1.1', '172.16.1.1'),641 ('http://user:pass@172.16.1.1:5000', '172.16.1.1'),642 ('http://hostname/', 'hostname'),643 ('http://hostname:5000/', 'hostname'),644 ('http://user:pass@hostname', 'hostname'),645 ('http://user:pass@hostname:5000', 'hostname'),646 ))647def test_should_bypass_proxies_pass_only_hostname(url, expected, mocker):648 """The proxy_bypass function should be called with a hostname or IP without649 a port number or auth credentials.650 """651 proxy_bypass = mocker.patch('requests.utils.proxy_bypass')652 should_bypass_proxies(url, no_proxy=None)653 proxy_bypass.assert_called_once_with(expected)654655656@pytest.mark.parametrize(657 'cookiejar', (658 compat.cookielib.CookieJar(),659 RequestsCookieJar()660 ))
3 unmodified lines
664 """665 cookiedict = {'test': 'cookies',666 'good': 'cookies'}667 cj = add_dict_to_cookiejar(cookiejar, cookiedict)570 cookies = dict((cookie.name, cookie.value) for cookie in cj)668 cookies = {cookie.name: cookie.value for cookie in cj}669 assert cookiedict == cookies670671672@pytest.mark.parametrize(
58 unmodified lines
731 def Close(self):732 pass733734 ie_settings = RegHandle()735 proxyEnableValues = deque([1, "1"])736737 def OpenKey(key, subkey):738 return ie_settings739740 def QueryValueEx(key, value_name):741 if key is ie_settings:742 if value_name == 'ProxyEnable':644 return [1]743 # this could be a string (REG_SZ) or a 32-bit number (REG_DWORD)744 proxyEnableValues.rotate()745 return [proxyEnableValues[0]]746 elif value_name == 'ProxyOverride':747 return [override]748749 monkeypatch.setenv('http_proxy', '')
2 unmodified lines
752 monkeypatch.setenv('no_proxy', '')753 monkeypatch.setenv('NO_PROXY', '')754 monkeypatch.setattr(winreg, 'OpenKey', OpenKey)755 monkeypatch.setattr(winreg, 'QueryValueEx', QueryValueEx)756 assert should_bypass_proxies(url, None) == expected757758759@pytest.mark.parametrize(760 'env_name, value', (
22 unmodified lines
modified:.gitignore+2 added
19 unmodified lines
20t.py2122t2.py23dist2425/.mypy_cache/
modified:.travis.yml+24 added-14 removed
1sudo: false2language: python3python:4 - "2.6"5 - "2.7"6 - "3.3"7 - "3.4"8 - "3.5"9 - "3.6"10 # - "3.7-dev"11 # - "pypy" -- appears to hang12 # - "pypy3"3# command to install dependencies4install: "make"5# command to run tests6script:
4 unmodified lines
11jobs:12 include:13 - stage: test14 script:25 - |26 if [[ "$TRAVIS_PYTHON_VERSION" != "2.6" ]] ; then make test-readme; fi15 - make test-readme16 - make ci17 python: '2.7'18 - stage: test19 script:20 - make test-readme21 - make ci22 python: '3.4'23 - stage: test24 script:25 - make test-readme26 - make ci27 python: '3.5'28 - stage: test29 script:30 - make test-readme31 - make ci32 python: '3.6'33 - stage: test34 script:35 - make test-readme36 - make ci37 python: '3.7'38 dist: xenial39 sudo: true 40 - stage: coverage41 python: 3.642 script: codecov3132
modified:appveyor.yml+10 added-9 removed
1# AppVeyor.yml from https://github.com/ogrisel/python-appveyor-demo2# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/2# License: CC0 1.0 Universal: https://creativecommons.org/publicdomain/zero/1.0/34build: off56environment:
2 unmodified lines
9 PYTHON_VERSION: "2.7.x"10 PYTHON_ARCH: "64"11 TOXENV: "py27"1213 - PYTHON: "C:\\Python33-x64"14 PYTHON_VERSION: "3.3.x"15 PYTHON_ARCH: "64"16 TOXENV: "py33"1713 - PYTHON: "C:\\Python34-x64"14 PYTHON_VERSION: "3.4.x"15 PYTHON_ARCH: "64"16 TOXENV: "py34"
7 unmodified lines
24 PYTHON_VERSION: "3.6.x"25 PYTHON_ARCH: "64"26 TOXENV: "py36"2728 - PYTHON: "C:\\Python37-x64"29 PYTHON_VERSION: "3.7.x"30 PYTHON_ARCH: "64"31 TOXENV: "py37"3233install:34 # Install Python (from the official .msi of http://python.org) and pip when34 # Install Python (from the official .msi of https://www.python.org/) and pip when35 # not already installed.36 - ps: if (-not(Test-Path($env:PYTHON))) { & _appveyor\install.ps1 }3738 # Prepend newly installed Python to the PATH of this build (this cannot be
6 unmodified lines
45 - "python -c \"import struct; print(struct.calcsize('P') * 8)\""4647 # Upgrade to the latest version of pip to avoid it displaying warnings48 # about it being out of date.49 - "pip install --disable-pip-version-check --user --upgrade pip"49 - "python -m pip install --upgrade pip wheel"50 - "C:\\MinGW\\bin\\mingw32-make"51 - "pipenv install -e .[socks] --skip-lock"5253test_script:54 - "C:\\MinGW\\bin\\mingw32-make coverage"5556on_success:56 - "codecov -f coverage.xml"57 - "pipenv run codecov -f coverage.xml"
modified:AUTHORS.rst+16 added-5 removed
1Requests is written and maintained by Kenneth Reitz and2various contributors:34Keepers of the Four Crystals5````````````````````````````4Keepers of the Crystals5```````````````````````67- Kenneth Reitz <me@kennethreitz.org> `@kennethreitz <https://github.com/kennethreitz>`_, Keeper of the Master Crystal.8- Ian Cordasco <graffatcolmingov@gmail.com> `@sigmavirus24 <https://github.com/sigmavirus24>`_.9- Nate Prewitt <nate.prewitt@gmail.com> `@nateprewitt <https://github.com/nateprewitt>`_.1011Previous Keepers of Crystals12````````````````````````````1314- Cory Benfield <cory@lukasa.co.uk> `@lukasa <https://github.com/lukasa>`_9- Ian Cordasco <graffatcolmingov@gmail.com> `@sigmavirus24 <https://github.com/sigmavirus24>`_10- Nate Prewitt <nate.prewitt@gmail.com> `@nateprewitt <https://github.com/nateprewitt>`_151617Patches and Suggestions18```````````````````````
105 unmodified lines
124- Dmitry Medvinsky <me@dmedvinsky.name>125- Bryce Boe <bbzbryce@gmail.com> (`@bboe <https://github.com/bboe>`_)126- Colin Dunklau <colin.dunklau@gmail.com> (`@cdunklau <https://github.com/cdunklau>`_)127- Bob Carroll <bob.carroll@alum.rit.edu> (`@rcarz <https://github.com/rcarz>`_)124- Hugo Osvaldo Barrera <hugo@osvaldobarrera.com.ar> (`@hobarrera <https://github.com/hobarrera>`_)128- Hugo Osvaldo Barrera <hugo@barrera.io> (`@hobarrera <https://github.com/hobarrera>`_)129- Łukasz Langa <lukasz@langa.pl>130- Dave Shawley <daveshawley@gmail.com>131- James Clarke (`@jam <https://github.com/jam>`_)132- Kevin Burke <kev@inburke.com>
48 unmodified lines
181- Gary Wu (`@garywu <https://github.com/garywu>`_)182- Ryan Pineo (`@ryanpineo <https://github.com/ryanpineo>`_)183- Ed Morley (`@edmorley <https://github.com/edmorley>`_)184- Matt Liu <liumatt@gmail.com> (`@mlcrazy <https://github.com/mlcrazy>`_)185- Taylor Hoff <primdevs@protonmail.com> (`@PrimordialHelios <https://github.com/PrimordialHelios>`_)186- Arthur Vigil (`@ahvigil <https://github.com/ahvigil>`_)187- Nehal J Wani (`@nehaljwani <https://github.com/nehaljwani>`_)188- Demetrios Bairaktaris (`@DemetriosBairaktaris <https://github.com/demetriosbairaktaris>`_)189- Darren Dormer (`@ddormer <https://github.com/ddormer>`_)190- Rajiv Mayani (`@mayani <https://github.com/mayani>`_)191- Antti Kaihola (`@akaihola <https://github.com/akaihola>`_)
added:HISTORY.md+1623 added
1Release History2===============34dev5---67**Bugfixes**89- \[Short description of non-trivial change.\]10112.20.0 (2018-10-18)12-------------------1314**Bugfixes**1516- Content-Type header parsing is now case-insensitive (e.g.17 charset=utf8 v Charset=utf8).18- Fixed exception leak where certain redirect urls would raise19 uncaught urllib3 exceptions.20- Requests removes Authorization header from requests redirected21 from https to http on the same hostname. (CVE-2018-18074)22- `should_bypass_proxies` now handles URIs without hostnames (e.g.23 files).2425**Dependencies**2627- Requests now supports urllib3 v1.24.2829**Deprecations**3031- Requests has officially stopped support for Python 2.6.32332.19.1 (2018-06-14)34-------------------3536**Bugfixes**3738- Fixed issue where status\_codes.py's `init` function failed trying39 to append to a `__doc__` value of `None`.40412.19.0 (2018-06-12)42-------------------4344**Improvements**4546- Warn user about possible slowdown when using cryptography version47 &lt; 1.3.448- Check for invalid host in proxy URL, before forwarding request to49 adapter.50- Fragments are now properly maintained across redirects. (RFC723151 7.1.2)52- Removed use of cgi module to expedite library load time.53- Added support for SHA-256 and SHA-512 digest auth algorithms.54- Minor performance improvement to `Request.content`.55- Migrate to using collections.abc for 3.7 compatibility.5657**Bugfixes**5859- Parsing empty `Link` headers with `parse_header_links()` no longer60 return one bogus entry.61- Fixed issue where loading the default certificate bundle from a zip62 archive would raise an `IOError`.63- Fixed issue with unexpected `ImportError` on windows system which do64 not support `winreg` module.65- DNS resolution in proxy bypass no longer includes the username and66 password in the request. This also fixes the issue of DNS queries67 failing on macOS.68- Properly normalize adapter prefixes for url comparison.69- Passing `None` as a file pointer to the `files` param no longer70 raises an exception.71- Calling `copy` on a `RequestsCookieJar` will now preserve the cookie72 policy correctly.7374**Dependencies**7576- We now support idna v2.7.77- We now support urllib3 v1.23.78792.18.4 (2017-08-15)80-------------------8182**Improvements**8384- Error messages for invalid headers now include the header name for85 easier debugging8687**Dependencies**8889- We now support idna v2.6.90912.18.3 (2017-08-02)92-------------------9394**Improvements**9596- Running `$ python -m requests.help` now includes the installed97 version of idna.9899**Bugfixes**100101- Fixed issue where Requests would raise `ConnectionError` instead of102 `SSLError` when encountering SSL problems when using urllib3 v1.22.1031042.18.2 (2017-07-25)105-------------------106107**Bugfixes**108109- `requests.help` no longer fails on Python 2.6 due to the absence of110 `ssl.OPENSSL_VERSION_NUMBER`.111112**Dependencies**113114- We now support urllib3 v1.22.1151162.18.1 (2017-06-14)117-------------------118119**Bugfixes**120121- Fix an error in the packaging whereby the `*.whl` contained122 incorrect data that regressed the fix in v2.17.3.1231242.18.0 (2017-06-14)125-------------------126127**Improvements**128129- `Response` is now a context manager, so can be used directly in a130 `with` statement without first having to be wrapped by131 `contextlib.closing()`.132133**Bugfixes**134135- Resolve installation failure if multiprocessing is not available136- Resolve tests crash if multiprocessing is not able to determine the137 number of CPU cores138- Resolve error swallowing in utils set\_environ generator1391402.17.3 (2017-05-29)141-------------------142143**Improvements**144145- Improved `packages` namespace identity support, for monkeypatching146 libraries.1471482.17.2 (2017-05-29)149-------------------150151**Improvements**152153- Improved `packages` namespace identity support, for monkeypatching154 libraries.1551562.17.1 (2017-05-29)157-------------------158159**Improvements**160161- Improved `packages` namespace identity support, for monkeypatching162 libraries.1631642.17.0 (2017-05-29)165-------------------166167**Improvements**168169- Removal of the 301 redirect cache. This improves thread-safety.1701712.16.5 (2017-05-28)172-------------------173174- Improvements to `$ python -m requests.help`.1751762.16.4 (2017-05-27)177-------------------178179- Introduction of the `$ python -m requests.help` command, for180 debugging with maintainers!1811822.16.3 (2017-05-27)183-------------------184185- Further restored the `requests.packages` namespace for compatibility186 reasons.1871882.16.2 (2017-05-27)189-------------------190191- Further restored the `requests.packages` namespace for compatibility192 reasons.193194No code modification (noted below) should be necessary any longer.1951962.16.1 (2017-05-27)197-------------------198199- Restored the `requests.packages` namespace for compatibility200 reasons.201- Bugfix for `urllib3` version parsing.202203**Note**: code that was written to import against the204`requests.packages` namespace previously will have to import code that205rests at this module-level now.206207For example:208209 from requests.packages.urllib3.poolmanager import PoolManager210211Will need to be re-written to be:212213 from requests.packages import urllib3214 urllib3.poolmanager.PoolManager215216Or, even better:217218 from urllib3.poolmanager import PoolManager2192202.16.0 (2017-05-26)221-------------------222223- Unvendor ALL the things!2242252.15.1 (2017-05-26)226-------------------227228- Everyone makes mistakes.2292302.15.0 (2017-05-26)231-------------------232233**Improvements**234235- Introduction of the `Response.next` property, for getting the next236 `PreparedResponse` from a redirect chain (when237 `allow_redirects=False`).238- Internal refactoring of `__version__` module.239240**Bugfixes**241242- Restored once-optional parameter for243 `requests.utils.get_environ_proxies()`.2442452.14.2 (2017-05-10)246-------------------247248**Bugfixes**249250- Changed a less-than to an equal-to and an or in the dependency251 markers to widen compatibility with older setuptools releases.2522532.14.1 (2017-05-09)254-------------------255256**Bugfixes**257258- Changed the dependency markers to widen compatibility with older pip259 releases.2602612.14.0 (2017-05-09)262-------------------263264**Improvements**265266- It is now possible to pass `no_proxy` as a key to the `proxies`267 dictionary to provide handling similar to the `NO_PROXY` environment268 variable.269- When users provide invalid paths to certificate bundle files or270 directories Requests now raises `IOError`, rather than failing at271 the time of the HTTPS request with a fairly inscrutable certificate272 validation error.273- The behavior of `SessionRedirectMixin` was slightly altered.274 `resolve_redirects` will now detect a redirect by calling275 `get_redirect_target(response)` instead of directly querying276 `Response.is_redirect` and `Response.headers['location']`. Advanced277 users will be able to process malformed redirects more easily.278- Changed the internal calculation of elapsed request time to have279 higher resolution on Windows.280- Added `win_inet_pton` as conditional dependency for the `[socks]`281 extra on Windows with Python 2.7.282- Changed the proxy bypass implementation on Windows: the proxy bypass283 check doesn't use forward and reverse DNS requests anymore284- URLs with schemes that begin with `http` but are not `http` or285 `https` no longer have their host parts forced to lowercase.286287**Bugfixes**288289- Much improved handling of non-ASCII `Location` header values in290 redirects. Fewer `UnicodeDecodeErrors` are encountered on Python 2,291 and Python 3 now correctly understands that Latin-1 is unlikely to292 be the correct encoding.293- If an attempt to `seek` file to find out its length fails, we now294 appropriately handle that by aborting our content-length295 calculations.296- Restricted `HTTPDigestAuth` to only respond to auth challenges made297 on 4XX responses, rather than to all auth challenges.298- Fixed some code that was firing `DeprecationWarning` on Python 3.6.299- The dismayed person emoticon (`/o\\`) no longer has a big head. I'm300 sure this is what you were all worrying about most.301302**Miscellaneous**303304- Updated bundled urllib3 to v1.21.1.305- Updated bundled chardet to v3.0.2.306- Updated bundled idna to v2.5.307- Updated bundled certifi to 2017.4.17.3083092.13.0 (2017-01-24)310-------------------311312**Features**313314- Only load the `idna` library when we've determined we need it. This315 will save some memory for users.316317**Miscellaneous**318319- Updated bundled urllib3 to 1.20.320- Updated bundled idna to 2.2.3213222.12.5 (2017-01-18)323-------------------324325**Bugfixes**326327- Fixed an issue with JSON encoding detection, specifically detecting328 big-endian UTF-32 with BOM.3293302.12.4 (2016-12-14)331-------------------332333**Bugfixes**334335- Fixed regression from 2.12.2 where non-string types were rejected in336 the basic auth parameters. While support for this behaviour has been337 readded, the behaviour is deprecated and will be removed in the338 future.3393402.12.3 (2016-12-01)341-------------------342343**Bugfixes**344345- Fixed regression from v2.12.1 for URLs with schemes that begin with346 "http". These URLs have historically been processed as though they347 were HTTP-schemed URLs, and so have had parameters added. This was348 removed in v2.12.2 in an overzealous attempt to resolve problems349 with IDNA-encoding those URLs. This change was reverted: the other350 fixes for IDNA-encoding have been judged to be sufficient to return351 to the behaviour Requests had before v2.12.0.3523532.12.2 (2016-11-30)354-------------------355356**Bugfixes**357358- Fixed several issues with IDNA-encoding URLs that are technically359 invalid but which are widely accepted. Requests will now attempt to360 IDNA-encode a URL if it can but, if it fails, and the host contains361 only ASCII characters, it will be passed through optimistically.362 This will allow users to opt-in to using IDNA2003 themselves if they363 want to, and will also allow technically invalid but still common364 hostnames.365- Fixed an issue where URLs with leading whitespace would raise366 `InvalidSchema` errors.367- Fixed an issue where some URLs without the HTTP or HTTPS schemes368 would still have HTTP URL preparation applied to them.369- Fixed an issue where Unicode strings could not be used in basic370 auth.371- Fixed an issue encountered by some Requests plugins where372 constructing a Response object would cause `Response.content` to373 raise an `AttributeError`.3743752.12.1 (2016-11-16)376-------------------377378**Bugfixes**379380- Updated setuptools 'security' extra for the new PyOpenSSL backend in381 urllib3.382383**Miscellaneous**384385- Updated bundled urllib3 to 1.19.1.3863872.12.0 (2016-11-15)388-------------------389390**Improvements**391392- Updated support for internationalized domain names from IDNA2003 to393 IDNA2008. This updated support is required for several forms of IDNs394 and is mandatory for .de domains.395- Much improved heuristics for guessing content lengths: Requests will396 no longer read an entire `StringIO` into memory.397- Much improved logic for recalculating `Content-Length` headers for398 `PreparedRequest` objects.399- Improved tolerance for file-like objects that have no `tell` method400 but do have a `seek` method.401- Anything that is a subclass of `Mapping` is now treated like a402 dictionary by the `data=` keyword argument.403- Requests now tolerates empty passwords in proxy credentials, rather404 than stripping the credentials.405- If a request is made with a file-like object as the body and that406 request is redirected with a 307 or 308 status code, Requests will407 now attempt to rewind the body object so it can be replayed.408409**Bugfixes**410411- When calling `response.close`, the call to `close` will be412 propagated through to non-urllib3 backends.413- Fixed issue where the `ALL_PROXY` environment variable would be414 preferred over scheme-specific variables like `HTTP_PROXY`.415- Fixed issue where non-UTF8 reason phrases got severely mangled by416 falling back to decoding using ISO 8859-1 instead.417- Fixed a bug where Requests would not correctly correlate cookies set418 when using custom Host headers if those Host headers did not use the419 native string type for the platform.420421**Miscellaneous**422423- Updated bundled urllib3 to 1.19.424- Updated bundled certifi certs to 2016.09.26.4254262.11.1 (2016-08-17)427-------------------428429**Bugfixes**430431- Fixed a bug when using `iter_content` with `decode_unicode=True` for432 streamed bodies would raise `AttributeError`. This bug was433 introduced in 2.11.434- Strip Content-Type and Transfer-Encoding headers from the header435 block when following a redirect that transforms the verb from436 POST/PUT to GET.4374382.11.0 (2016-08-08)439-------------------440441**Improvements**442443- Added support for the `ALL_PROXY` environment variable.444- Reject header values that contain leading whitespace or newline445 characters to reduce risk of header smuggling.446447**Bugfixes**448449- Fixed occasional `TypeError` when attempting to decode a JSON450 response that occurred in an error case. Now correctly returns a451 `ValueError`.452- Requests would incorrectly ignore a non-CIDR IP address in the453 `NO_PROXY` environment variables: Requests now treats it as a454 specific IP.455- Fixed a bug when sending JSON data that could cause us to encounter456 obscure OpenSSL errors in certain network conditions (yes, really).457- Added type checks to ensure that `iter_content` only accepts458 integers and `None` for chunk sizes.459- Fixed issue where responses whose body had not been fully consumed460 would have the underlying connection closed but not returned to the461 connection pool, which could cause Requests to hang in situations462 where the `HTTPAdapter` had been configured to use a blocking463 connection pool.464465**Miscellaneous**466467- Updated bundled urllib3 to 1.16.468- Some previous releases accidentally accepted non-strings as469 acceptable header values. This release does not.4704712.10.0 (2016-04-29)472-------------------473474**New Features**475476- SOCKS Proxy Support! (requires PySocks;477 `$ pip install requests[socks]`)478479**Miscellaneous**480481- Updated bundled urllib3 to 1.15.1.4824832.9.2 (2016-04-29)484------------------485486**Improvements**487488- Change built-in CaseInsensitiveDict (used for headers) to use489 OrderedDict as its underlying datastore.490491**Bugfixes**492493- Don't use redirect\_cache if allow\_redirects=False494- When passed objects that throw exceptions from `tell()`, send them495 via chunked transfer encoding instead of failing.496- Raise a ProxyError for proxy related connection issues.4974982.9.1 (2015-12-21)499------------------500501**Bugfixes**502503- Resolve regression introduced in 2.9.0 that made it impossible to504 send binary strings as bodies in Python 3.505- Fixed errors when calculating cookie expiration dates in certain506 locales.507508**Miscellaneous**509510- Updated bundled urllib3 to 1.13.1.5115122.9.0 (2015-12-15)513------------------514515**Minor Improvements** (Backwards compatible)516517- The `verify` keyword argument now supports being passed a path to a518 directory of CA certificates, not just a single-file bundle.519- Warnings are now emitted when sending files opened in text mode.520- Added the 511 Network Authentication Required status code to the521 status code registry.522523**Bugfixes**524525- For file-like objects that are not seeked to the very beginning, we526 now send the content length for the number of bytes we will actually527 read, rather than the total size of the file, allowing partial file528 uploads.529- When uploading file-like objects, if they are empty or have no530 obvious content length we set `Transfer-Encoding: chunked` rather531 than `Content-Length: 0`.532- We correctly receive the response in buffered mode when uploading533 chunked bodies.534- We now handle being passed a query string as a bytestring on Python535 3, by decoding it as UTF-8.536- Sessions are now closed in all cases (exceptional and not) when537 using the functional API rather than leaking and waiting for the538 garbage collector to clean them up.539- Correctly handle digest auth headers with a malformed `qop`540 directive that contains no token, by treating it the same as if no541 `qop` directive was provided at all.542- Minor performance improvements when removing specific cookies by543 name.544545**Miscellaneous**546547- Updated urllib3 to 1.13.5485492.8.1 (2015-10-13)550------------------551552**Bugfixes**553554- Update certificate bundle to match `certifi` 2015.9.6.2's weak555 certificate bundle.556- Fix a bug in 2.8.0 where requests would raise `ConnectTimeout`557 instead of `ConnectionError`558- When using the PreparedRequest flow, requests will now correctly559 respect the `json` parameter. Broken in 2.8.0.560- When using the PreparedRequest flow, requests will now correctly561 handle a Unicode-string method name on Python 2. Broken in 2.8.0.5625632.8.0 (2015-10-05)564------------------565566**Minor Improvements** (Backwards Compatible)567568- Requests now supports per-host proxies. This allows the `proxies`569 dictionary to have entries of the form570 `{'<scheme>://<hostname>': '<proxy>'}`. Host-specific proxies will571 be used in preference to the previously-supported scheme-specific572 ones, but the previous syntax will continue to work.573- `Response.raise_for_status` now prints the URL that failed as part574 of the exception message.575- `requests.utils.get_netrc_auth` now takes an `raise_errors` kwarg,576 defaulting to `False`. When `True`, errors parsing `.netrc` files577 cause exceptions to be thrown.578- Change to bundled projects import logic to make it easier to579 unbundle requests downstream.580- Changed the default User-Agent string to avoid leaking data on581 Linux: now contains only the requests version.582583**Bugfixes**584585- The `json` parameter to `post()` and friends will now only be used586 if neither `data` nor `files` are present, consistent with the587 documentation.588- We now ignore empty fields in the `NO_PROXY` environment variable.589- Fixed problem where `httplib.BadStatusLine` would get raised if590 combining `stream=True` with `contextlib.closing`.591- Prevented bugs where we would attempt to return the same connection592 back to the connection pool twice when sending a Chunked body.593- Miscellaneous minor internal changes.594- Digest Auth support is now thread safe.595596**Updates**597598- Updated urllib3 to 1.12.5996002.7.0 (2015-05-03)601------------------602603This is the first release that follows our new release process. For604more, see [our605documentation](http://docs.python-requests.org/en/latest/community/release-process/).606607**Bugfixes**608609- Updated urllib3 to 1.10.4, resolving several bugs involving chunked610 transfer encoding and response framing.6116122.6.2 (2015-04-23)613------------------614615**Bugfixes**616617- Fix regression where compressed data that was sent as chunked data618 was not properly decompressed. (\#2561)6196202.6.1 (2015-04-22)621------------------622623**Bugfixes**624625- Remove VendorAlias import machinery introduced in v2.5.2.626- Simplify the PreparedRequest.prepare API: We no longer require the627 user to pass an empty list to the hooks keyword argument. (c.f.628 \#2552)629- Resolve redirects now receives and forwards all of the original630 arguments to the adapter. (\#2503)631- Handle UnicodeDecodeErrors when trying to deal with a unicode URL632 that cannot be encoded in ASCII. (\#2540)633- Populate the parsed path of the URI field when performing Digest634 Authentication. (\#2426)635- Copy a PreparedRequest's CookieJar more reliably when it is not an636 instance of RequestsCookieJar. (\#2527)6376382.6.0 (2015-03-14)639------------------640641**Bugfixes**642643- CVE-2015-2296: Fix handling of cookies on redirect. Previously a644 cookie without a host value set would use the hostname for the645 redirected URL exposing requests users to session fixation attacks646 and potentially cookie stealing. This was disclosed privately by647 Matthew Daley of [BugFuzz](https://bugfuzz.com). This affects all648 versions of requests from v2.1.0 to v2.5.3 (inclusive on both ends).649- Fix error when requests is an `install_requires` dependency and650 `python setup.py test` is run. (\#2462)651- Fix error when urllib3 is unbundled and requests continues to use652 the vendored import location.653- Include fixes to `urllib3`'s header handling.654- Requests' handling of unvendored dependencies is now more655 restrictive.656657**Features and Improvements**658659- Support bytearrays when passed as parameters in the `files`660 argument. (\#2468)661- Avoid data duplication when creating a request with `str`, `bytes`,662 or `bytearray` input to the `files` argument.6636642.5.3 (2015-02-24)665------------------666667**Bugfixes**668669- Revert changes to our vendored certificate bundle. For more context670 see (\#2455, \#2456, and <https://bugs.python.org/issue23476>)6716722.5.2 (2015-02-23)673------------------674675**Features and Improvements**676677- Add sha256 fingerprint support.678 ([shazow/urllib3\#540](https://github.com/shazow/urllib3/pull/540))679- Improve the performance of headers.680 ([shazow/urllib3\#544](https://github.com/shazow/urllib3/pull/544))681682**Bugfixes**683684- Copy pip's import machinery. When downstream redistributors remove685 requests.packages.urllib3 the import machinery will continue to let686 those same symbols work. Example usage in requests' documentation687 and 3rd-party libraries relying on the vendored copies of urllib3688 will work without having to fallback to the system urllib3.689- Attempt to quote parts of the URL on redirect if unquoting and then690 quoting fails. (\#2356)691- Fix filename type check for multipart form-data uploads. (\#2411)692- Properly handle the case where a server issuing digest693 authentication challenges provides both auth and auth-int694 qop-values. (\#2408)695- Fix a socket leak.696 ([shazow/urllib3\#549](https://github.com/shazow/urllib3/pull/549))697- Fix multiple `Set-Cookie` headers properly.698 ([shazow/urllib3\#534](https://github.com/shazow/urllib3/pull/534))699- Disable the built-in hostname verification.700 ([shazow/urllib3\#526](https://github.com/shazow/urllib3/pull/526))701- Fix the behaviour of decoding an exhausted stream.702 ([shazow/urllib3\#535](https://github.com/shazow/urllib3/pull/535))703704**Security**705706- Pulled in an updated `cacert.pem`.707- Drop RC4 from the default cipher list.708 ([shazow/urllib3\#551](https://github.com/shazow/urllib3/pull/551))7097102.5.1 (2014-12-23)711------------------712713**Behavioural Changes**714715- Only catch HTTPErrors in raise\_for\_status (\#2382)716717**Bugfixes**718719- Handle LocationParseError from urllib3 (\#2344)720- Handle file-like object filenames that are not strings (\#2379)721- Unbreak HTTPDigestAuth handler. Allow new nonces to be negotiated722 (\#2389)7237242.5.0 (2014-12-01)725------------------726727**Improvements**728729- Allow usage of urllib3's Retry object with HTTPAdapters (\#2216)730- The `iter_lines` method on a response now accepts a delimiter with731 which to split the content (\#2295)732733**Behavioural Changes**734735- Add deprecation warnings to functions in requests.utils that will be736 removed in 3.0 (\#2309)737- Sessions used by the functional API are always closed (\#2326)738- Restrict requests to HTTP/1.1 and HTTP/1.0 (stop accepting HTTP/0.9)739 (\#2323)740741**Bugfixes**742743- Only parse the URL once (\#2353)744- Allow Content-Length header to always be overridden (\#2332)745- Properly handle files in HTTPDigestAuth (\#2333)746- Cap redirect\_cache size to prevent memory abuse (\#2299)747- Fix HTTPDigestAuth handling of redirects after authenticating748 successfully (\#2253)749- Fix crash with custom method parameter to Session.request (\#2317)750- Fix how Link headers are parsed using the regular expression library751 (\#2271)752753**Documentation**754755- Add more references for interlinking (\#2348)756- Update CSS for theme (\#2290)757- Update width of buttons and sidebar (\#2289)758- Replace references of Gittip with Gratipay (\#2282)759- Add link to changelog in sidebar (\#2273)7607612.4.3 (2014-10-06)762------------------763764**Bugfixes**765766- Unicode URL improvements for Python 2.767- Re-order JSON param for backwards compat.768- Automatically defrag authentication schemes from host/pass URIs.769 ([\#2249](https://github.com/requests/requests/issues/2249))7707712.4.2 (2014-10-05)772------------------773774**Improvements**775776- FINALLY! Add json parameter for uploads!777 ([\#2258](https://github.com/requests/requests/pull/2258))778- Support for bytestring URLs on Python 3.x779 ([\#2238](https://github.com/requests/requests/pull/2238))780781**Bugfixes**782783- Avoid getting stuck in a loop784 ([\#2244](https://github.com/requests/requests/pull/2244))785- Multiple calls to iter\* fail with unhelpful error.786 ([\#2240](https://github.com/requests/requests/issues/2240),787 [\#2241](https://github.com/requests/requests/issues/2241))788789**Documentation**790791- Correct redirection introduction792 ([\#2245](https://github.com/requests/requests/pull/2245/))793- Added example of how to send multiple files in one request.794 ([\#2227](https://github.com/requests/requests/pull/2227/))795- Clarify how to pass a custom set of CAs796 ([\#2248](https://github.com/requests/requests/pull/2248/))7977982.4.1 (2014-09-09)799------------------800801- Now has a "security" package extras set,802 `$ pip install requests[security]`803- Requests will now use Certifi if it is available.804- Capture and re-raise urllib3 ProtocolError805- Bugfix for responses that attempt to redirect to themselves forever806 (wtf?).8078082.4.0 (2014-08-29)809------------------810811**Behavioral Changes**812813- `Connection: keep-alive` header is now sent automatically.814815**Improvements**816817- Support for connect timeouts! Timeout now accepts a tuple (connect,818 read) which is used to set individual connect and read timeouts.819- Allow copying of PreparedRequests without headers/cookies.820- Updated bundled urllib3 version.821- Refactored settings loading from environment -- new822 Session.merge\_environment\_settings.823- Handle socket errors in iter\_content.8248252.3.0 (2014-05-16)826------------------827828**API Changes**829830- New `Response` property `is_redirect`, which is true when the831 library could have processed this response as a redirection (whether832 or not it actually did).833- The `timeout` parameter now affects requests with both `stream=True`834 and `stream=False` equally.835- The change in v2.0.0 to mandate explicit proxy schemes has been836 reverted. Proxy schemes now default to `http://`.837- The `CaseInsensitiveDict` used for HTTP headers now behaves like a838 normal dictionary when references as string or viewed in the839 interpreter.840841**Bugfixes**842843- No longer expose Authorization or Proxy-Authorization headers on844 redirect. Fix CVE-2014-1829 and CVE-2014-1830 respectively.845- Authorization is re-evaluated each redirect.846- On redirect, pass url as native strings.847- Fall-back to autodetected encoding for JSON when Unicode detection848 fails.849- Headers set to `None` on the `Session` are now correctly not sent.850- Correctly honor `decode_unicode` even if it wasn't used earlier in851 the same response.852- Stop advertising `compress` as a supported Content-Encoding.853- The `Response.history` parameter is now always a list.854- Many, many `urllib3` bugfixes.8558562.2.1 (2014-01-23)857------------------858859**Bugfixes**860861- Fixes incorrect parsing of proxy credentials that contain a literal862 or encoded '\#' character.863- Assorted urllib3 fixes.8648652.2.0 (2014-01-09)866------------------867868**API Changes**869870- New exception: `ContentDecodingError`. Raised instead of `urllib3`871 `DecodeError` exceptions.872873**Bugfixes**874875- Avoid many many exceptions from the buggy implementation of876 `proxy_bypass` on OS X in Python 2.6.877- Avoid crashing when attempting to get authentication credentials878 from \~/.netrc when running as a user without a home directory.879- Use the correct pool size for pools of connections to proxies.880- Fix iteration of `CookieJar` objects.881- Ensure that cookies are persisted over redirect.882- Switch back to using chardet, since it has merged with charade.8838842.1.0 (2013-12-05)885------------------886887- Updated CA Bundle, of course.888- Cookies set on individual Requests through a `Session` (e.g. via889 `Session.get()`) are no longer persisted to the `Session`.890- Clean up connections when we hit problems during chunked upload,891 rather than leaking them.892- Return connections to the pool when a chunked upload is successful,893 rather than leaking it.894- Match the HTTPbis recommendation for HTTP 301 redirects.895- Prevent hanging when using streaming uploads and Digest Auth when a896 401 is received.897- Values of headers set by Requests are now always the native string898 type.899- Fix previously broken SNI support.900- Fix accessing HTTP proxies using proxy authentication.901- Unencode HTTP Basic usernames and passwords extracted from URLs.902- Support for IP address ranges for no\_proxy environment variable903- Parse headers correctly when users override the default `Host:`904 header.905- Avoid munging the URL in case of case-sensitive servers.906- Looser URL handling for non-HTTP/HTTPS urls.907- Accept unicode methods in Python 2.6 and 2.7.908- More resilient cookie handling.909- Make `Response` objects pickleable.910- Actually added MD5-sess to Digest Auth instead of pretending to like911 last time.912- Updated internal urllib3.913- Fixed @Lukasa's lack of taste.9149152.0.1 (2013-10-24)916------------------917918- Updated included CA Bundle with new mistrusts and automated process919 for the future920- Added MD5-sess to Digest Auth921- Accept per-file headers in multipart file POST messages.922- Fixed: Don't send the full URL on CONNECT messages.923- Fixed: Correctly lowercase a redirect scheme.924- Fixed: Cookies not persisted when set via functional API.925- Fixed: Translate urllib3 ProxyError into a requests ProxyError926 derived from ConnectionError.927- Updated internal urllib3 and chardet.9289292.0.0 (2013-09-24)930------------------931932**API Changes:**933934- Keys in the Headers dictionary are now native strings on all Python935 versions, i.e. bytestrings on Python 2, unicode on Python 3.936- Proxy URLs now *must* have an explicit scheme. A `MissingSchema`937 exception will be raised if they don't.938- Timeouts now apply to read time if `Stream=False`.939- `RequestException` is now a subclass of `IOError`, not940 `RuntimeError`.941- Added new method to `PreparedRequest` objects:942 `PreparedRequest.copy()`.943- Added new method to `Session` objects: `Session.update_request()`.944 This method updates a `Request` object with the data (e.g. cookies)945 stored on the `Session`.946- Added new method to `Session` objects: `Session.prepare_request()`.947 This method updates and prepares a `Request` object, and returns the948 corresponding `PreparedRequest` object.949- Added new method to `HTTPAdapter` objects:950 `HTTPAdapter.proxy_headers()`. This should not be called directly,951 but improves the subclass interface.952- `httplib.IncompleteRead` exceptions caused by incorrect chunked953 encoding will now raise a Requests `ChunkedEncodingError` instead.954- Invalid percent-escape sequences now cause a Requests `InvalidURL`955 exception to be raised.956- HTTP 208 no longer uses reason phrase `"im_used"`. Correctly uses957 `"already_reported"`.958- HTTP 226 reason added (`"im_used"`).959960**Bugfixes:**961962- Vastly improved proxy support, including the CONNECT verb. Special963 thanks to the many contributors who worked towards this improvement.964- Cookies are now properly managed when 401 authentication responses965 are received.966- Chunked encoding fixes.967- Support for mixed case schemes.968- Better handling of streaming downloads.969- Retrieve environment proxies from more locations.970- Minor cookies fixes.971- Improved redirect behaviour.972- Improved streaming behaviour, particularly for compressed data.973- Miscellaneous small Python 3 text encoding bugs.974- `.netrc` no longer overrides explicit auth.975- Cookies set by hooks are now correctly persisted on Sessions.976- Fix problem with cookies that specify port numbers in their host977 field.978- `BytesIO` can be used to perform streaming uploads.979- More generous parsing of the `no_proxy` environment variable.980- Non-string objects can be passed in data values alongside files.9819821.2.3 (2013-05-25)983------------------984985- Simple packaging fix9869871.2.2 (2013-05-23)988------------------989990- Simple packaging fix9919921.2.1 (2013-05-20)993------------------994995- 301 and 302 redirects now change the verb to GET for all verbs, not996 just POST, improving browser compatibility.997- Python 3.3.2 compatibility998- Always percent-encode location headers999- Fix connection adapter matching to be most-specific first1000- new argument to the default connection adapter for passing a block1001 argument1002- prevent a KeyError when there's no link headers100310041.2.0 (2013-03-31)1005------------------10061007- Fixed cookies on sessions and on requests1008- Significantly change how hooks are dispatched - hooks now receive1009 all the arguments specified by the user when making a request so1010 hooks can make a secondary request with the same parameters. This is1011 especially necessary for authentication handler authors1012- certifi support was removed1013- Fixed bug where using OAuth 1 with body `signature_type` sent no1014 data1015- Major proxy work thanks to @Lukasa including parsing of proxy1016 authentication from the proxy url1017- Fix DigestAuth handling too many 401s1018- Update vendored urllib3 to include SSL bug fixes1019- Allow keyword arguments to be passed to `json.loads()` via the1020 `Response.json()` method1021- Don't send `Content-Length` header by default on `GET` or `HEAD`1022 requests1023- Add `elapsed` attribute to `Response` objects to time how long a1024 request took.1025- Fix `RequestsCookieJar`1026- Sessions and Adapters are now picklable, i.e., can be used with the1027 multiprocessing library1028- Update charade to version 1.0.310291030The change in how hooks are dispatched will likely cause a great deal of1031issues.103210331.1.0 (2013-01-10)1034------------------10351036- CHUNKED REQUESTS1037- Support for iterable response bodies1038- Assume servers persist redirect params1039- Allow explicit content types to be specified for file data1040- Make merge\_kwargs case-insensitive when looking up keys104110421.0.3 (2012-12-18)1043------------------10441045- Fix file upload encoding bug1046- Fix cookie behavior104710481.0.2 (2012-12-17)1049------------------10501051- Proxy fix for HTTPAdapter.105210531.0.1 (2012-12-17)1054------------------10551056- Cert verification exception bug.1057- Proxy fix for HTTPAdapter.105810591.0.0 (2012-12-17)1060------------------10611062- Massive Refactor and Simplification1063- Switch to Apache 2.0 license1064- Swappable Connection Adapters1065- Mountable Connection Adapters1066- Mutable ProcessedRequest chain1067- /s/prefetch/stream1068- Removal of all configuration1069- Standard library logging1070- Make Response.json() callable, not property.1071- Usage of new charade project, which provides python 2 and 31072 simultaneous chardet.1073- Removal of all hooks except 'response'1074- Removal of all authentication helpers (OAuth, Kerberos)10751076This is not a backwards compatible change.107710780.14.2 (2012-10-27)1079-------------------10801081- Improved mime-compatible JSON handling1082- Proxy fixes1083- Path hack fixes1084- Case-Insensitive Content-Encoding headers1085- Support for CJK parameters in form posts108610870.14.1 (2012-10-01)1088-------------------10891090- Python 3.3 Compatibility1091- Simply default accept-encoding1092- Bugfixes109310940.14.0 (2012-09-02)1095-------------------10961097- No more iter\_content errors if already downloaded.109810990.13.9 (2012-08-25)1100-------------------11011102- Fix for OAuth + POSTs1103- Remove exception eating from dispatch\_hook1104- General bugfixes110511060.13.8 (2012-08-21)1107-------------------11081109- Incredible Link header support :)111011110.13.7 (2012-08-19)1112-------------------11131114- Support for (key, value) lists everywhere.1115- Digest Authentication improvements.1116- Ensure proxy exclusions work properly.1117- Clearer UnicodeError exceptions.1118- Automatic casting of URLs to strings (fURL and such)1119- Bugfixes.112011210.13.6 (2012-08-06)1122-------------------11231124- Long awaited fix for hanging connections!112511260.13.5 (2012-07-27)1127-------------------11281129- Packaging fix113011310.13.4 (2012-07-27)1132-------------------11331134- GSSAPI/Kerberos authentication!1135- App Engine 2.7 Fixes!1136- Fix leaking connections (from urllib3 update)1137- OAuthlib path hack fix1138- OAuthlib URL parameters fix.113911400.13.3 (2012-07-12)1141-------------------11421143- Use simplejson if available.1144- Do not hide SSLErrors behind Timeouts.1145- Fixed param handling with urls containing fragments.1146- Significantly improved information in User Agent.1147- client certificates are ignored when verify=False114811490.13.2 (2012-06-28)1150-------------------11511152- Zero dependencies (once again)!1153- New: Response.reason1154- Sign querystring parameters in OAuth 1.01155- Client certificates no longer ignored when verify=False1156- Add openSUSE certificate support115711580.13.1 (2012-06-07)1159-------------------11601161- Allow passing a file or file-like object as data.1162- Allow hooks to return responses that indicate errors.1163- Fix Response.text and Response.json for body-less responses.116411650.13.0 (2012-05-29)1166-------------------11671168- Removal of Requests.async in favor of1169 [grequests](https://github.com/kennethreitz/grequests)1170- Allow disabling of cookie persistence.1171- New implementation of safe\_mode1172- cookies.get now supports default argument1173- Session cookies not saved when Session.request is called with1174 return\_response=False1175- Env: no\_proxy support.1176- RequestsCookieJar improvements.1177- Various bug fixes.117811790.12.1 (2012-05-08)1180-------------------11811182- New `Response.json` property.1183- Ability to add string file uploads.1184- Fix out-of-range issue with iter\_lines.1185- Fix iter\_content default size.1186- Fix POST redirects containing files.118711880.12.0 (2012-05-02)1189-------------------11901191- EXPERIMENTAL OAUTH SUPPORT!1192- Proper CookieJar-backed cookies interface with awesome dict-like1193 interface.1194- Speed fix for non-iterated content chunks.1195- Move `pre_request` to a more usable place.1196- New `pre_send` hook.1197- Lazily encode data, params, files.1198- Load system Certificate Bundle if `certify` isn't available.1199- Cleanups, fixes.120012010.11.2 (2012-04-22)1202-------------------12031204- Attempt to use the OS's certificate bundle if `certifi` isn't1205 available.1206- Infinite digest auth redirect fix.1207- Multi-part file upload improvements.1208- Fix decoding of invalid %encodings in URLs.1209- If there is no content in a response don't throw an error the second1210 time that content is attempted to be read.1211- Upload data on redirects.121212130.11.1 (2012-03-30)1214-------------------12151216- POST redirects now break RFC to do what browsers do: Follow up with1217 a GET.1218- New `strict_mode` configuration to disable new redirect behavior.121912200.11.0 (2012-03-14)1221-------------------12221223- Private SSL Certificate support1224- Remove select.poll from Gevent monkeypatching1225- Remove redundant generator for chunked transfer encoding1226- Fix: Response.ok raises Timeout Exception in safe\_mode122712280.10.8 (2012-03-09)1229-------------------12301231- Generate chunked ValueError fix1232- Proxy configuration by environment variables1233- Simplification of iter\_lines.1234- New trust\_env configuration for disabling system/environment hints.1235- Suppress cookie errors.123612370.10.7 (2012-03-07)1238-------------------12391240- encode\_uri = False124112420.10.6 (2012-02-25)1243-------------------12441245- Allow '=' in cookies.124612470.10.5 (2012-02-25)1248-------------------12491250- Response body with 0 content-length fix.1251- New async.imap.1252- Don't fail on netrc.125312540.10.4 (2012-02-20)1255-------------------12561257- Honor netrc.125812590.10.3 (2012-02-20)1260-------------------12611262- HEAD requests don't follow redirects anymore.1263- raise\_for\_status() doesn't raise for 3xx anymore.1264- Make Session objects picklable.1265- ValueError for invalid schema URLs.126612670.10.2 (2012-01-15)1268-------------------12691270- Vastly improved URL quoting.1271- Additional allowed cookie key values.1272- Attempted fix for "Too many open files" Error1273- Replace unicode errors on first pass, no need for second pass.1274- Append '/' to bare-domain urls before query insertion.1275- Exceptions now inherit from RuntimeError.1276- Binary uploads + auth fix.1277- Bugfixes.127812790.10.1 (2012-01-23)1280-------------------12811282- PYTHON 3 SUPPORT!1283- Dropped 2.5 Support. (*Backwards Incompatible*)128412850.10.0 (2012-01-21)1286-------------------12871288- `Response.content` is now bytes-only. (*Backwards Incompatible*)1289- New `Response.text` is unicode-only.1290- If no `Response.encoding` is specified and `chardet` is available,1291 `Response.text` will guess an encoding.1292- Default to ISO-8859-1 (Western) encoding for "text" subtypes.1293- Removal of decode\_unicode. (*Backwards Incompatible*)1294- New multiple-hooks system.1295- New `Response.register_hook` for registering hooks within the1296 pipeline.1297- `Response.url` is now Unicode.129812990.9.3 (2012-01-18)1300------------------13011302- SSL verify=False bugfix (apparent on windows machines).130313040.9.2 (2012-01-18)1305------------------13061307- Asynchronous async.send method.1308- Support for proper chunk streams with boundaries.1309- session argument for Session classes.1310- Print entire hook tracebacks, not just exception instance.1311- Fix response.iter\_lines from pending next line.1312- Fix but in HTTP-digest auth w/ URI having query strings.1313- Fix in Event Hooks section.1314- Urllib3 update.131513160.9.1 (2012-01-06)1317------------------13181319- danger\_mode for automatic Response.raise\_for\_status()1320- Response.iter\_lines refactor132113220.9.0 (2011-12-28)1323------------------13241325- verify ssl is default.132613270.8.9 (2011-12-28)1328------------------13291330- Packaging fix.133113320.8.8 (2011-12-28)1333------------------13341335- SSL CERT VERIFICATION!1336- Release of Cerifi: Mozilla's cert list.1337- New 'verify' argument for SSL requests.1338- Urllib3 update.133913400.8.7 (2011-12-24)1341------------------13421343- iter\_lines last-line truncation fix1344- Force safe\_mode for async requests1345- Handle safe\_mode exceptions more consistently1346- Fix iteration on null responses in safe\_mode134713480.8.6 (2011-12-18)1349------------------13501351- Socket timeout fixes.1352- Proxy Authorization support.135313540.8.5 (2011-12-14)1355------------------13561357- Response.iter\_lines!135813590.8.4 (2011-12-11)1360------------------13611362- Prefetch bugfix.1363- Added license to installed version.136413650.8.3 (2011-11-27)1366------------------13671368- Converted auth system to use simpler callable objects.1369- New session parameter to API methods.1370- Display full URL while logging.137113720.8.2 (2011-11-19)1373------------------13741375- New Unicode decoding system, based on over-ridable1376 Response.encoding.1377- Proper URL slash-quote handling.1378- Cookies with `[`, `]`, and `_` allowed.137913800.8.1 (2011-11-15)1381------------------13821383- URL Request path fix1384- Proxy fix.1385- Timeouts fix.138613870.8.0 (2011-11-13)1388------------------13891390- Keep-alive support!1391- Complete removal of Urllib21392- Complete removal of Poster1393- Complete removal of CookieJars1394- New ConnectionError raising1395- Safe\_mode for error catching1396- prefetch parameter for request methods1397- OPTION method1398- Async pool size throttling1399- File uploads send real names1400- Vendored in urllib3140114020.7.6 (2011-11-07)1403------------------14041405- Digest authentication bugfix (attach query data to path)140614070.7.5 (2011-11-04)1408------------------14091410- Response.content = None if there was an invalid response.1411- Redirection auth handling.141214130.7.4 (2011-10-26)1414------------------14151416- Session Hooks fix.141714180.7.3 (2011-10-23)1419------------------14201421- Digest Auth fix.142214230.7.2 (2011-10-23)1424------------------14251426- PATCH Fix.142714280.7.1 (2011-10-23)1429------------------14301431- Move away from urllib2 authentication handling.1432- Fully Remove AuthManager, AuthObject, &c.1433- New tuple-based auth system with handler callbacks.143414350.7.0 (2011-10-22)1436------------------14371438- Sessions are now the primary interface.1439- Deprecated InvalidMethodException.1440- PATCH fix.1441- New config system (no more global settings).144214430.6.6 (2011-10-19)1444------------------14451446- Session parameter bugfix (params merging).144714480.6.5 (2011-10-18)1449------------------14501451- Offline (fast) test suite.1452- Session dictionary argument merging.145314540.6.4 (2011-10-13)1455------------------14561457- Automatic decoding of unicode, based on HTTP Headers.1458- New `decode_unicode` setting.1459- Removal of `r.read/close` methods.1460- New `r.faw` interface for advanced response usage.\*1461- Automatic expansion of parameterized headers.146214630.6.3 (2011-10-13)1464------------------14651466- Beautiful `requests.async` module, for making async requests w/1467 gevent.146814690.6.2 (2011-10-09)1470------------------14711472- GET/HEAD obeys allow\_redirects=False.147314740.6.1 (2011-08-20)1475------------------14761477- Enhanced status codes experience `\o/`1478- Set a maximum number of redirects (`settings.max_redirects`)1479- Full Unicode URL support1480- Support for protocol-less redirects.1481- Allow for arbitrary request types.1482- Bugfixes148314840.6.0 (2011-08-17)1485------------------14861487- New callback hook system1488- New persistent sessions object and context manager1489- Transparent Dict-cookie handling1490- Status code reference object1491- Removed Response.cached1492- Added Response.request1493- All args are kwargs1494- Relative redirect support1495- HTTPError handling improvements1496- Improved https testing1497- Bugfixes149814990.5.1 (2011-07-23)1500------------------15011502- International Domain Name Support!1503- Access headers without fetching entire body (`read()`)1504- Use lists as dicts for parameters1505- Add Forced Basic Authentication1506- Forced Basic is default authentication type1507- `python-requests.org` default User-Agent header1508- CaseInsensitiveDict lower-case caching1509- Response.history bugfix151015110.5.0 (2011-06-21)1512------------------15131514- PATCH Support1515- Support for Proxies1516- HTTPBin Test Suite1517- Redirect Fixes1518- settings.verbose stream writing1519- Querystrings for all methods1520- URLErrors (Connection Refused, Timeout, Invalid URLs) are treated as1521 explicitly raised1522 `r.requests.get('hwe://blah'); r.raise_for_status()`152315240.4.1 (2011-05-22)1525------------------15261527- Improved Redirection Handling1528- New 'allow\_redirects' param for following non-GET/HEAD Redirects1529- Settings module refactoring153015310.4.0 (2011-05-15)1532------------------15331534- Response.history: list of redirected responses1535- Case-Insensitive Header Dictionaries!1536- Unicode URLs153715380.3.4 (2011-05-14)1539------------------15401541- Urllib2 HTTPAuthentication Recursion fix (Basic/Digest)1542- Internal Refactor1543- Bytes data upload Bugfix154415450.3.3 (2011-05-12)1546------------------15471548- Request timeouts1549- Unicode url-encoded data1550- Settings context manager and module155115520.3.2 (2011-04-15)1553------------------15541555- Automatic Decompression of GZip Encoded Content1556- AutoAuth Support for Tupled HTTP Auth155715580.3.1 (2011-04-01)1559------------------15601561- Cookie Changes1562- Response.read()1563- Poster fix156415650.3.0 (2011-02-25)1566------------------15671568- Automatic Authentication API Change1569- Smarter Query URL Parameterization1570- Allow file uploads and POST data together1571- 15721573 New Authentication Manager System15741575 : - Simpler Basic HTTP System1576 - Supports all build-in urllib2 Auths1577 - Allows for custom Auth Handlers157815790.2.4 (2011-02-19)1580------------------15811582- Python 2.5 Support1583- PyPy-c v1.4 Support1584- Auto-Authentication tests1585- Improved Request object constructor158615870.2.3 (2011-02-15)1588------------------15891590- 15911592 New HTTPHandling Methods15931594 : - Response.\_\_nonzero\_\_ (false if bad HTTP Status)1595 - Response.ok (True if expected HTTP Status)1596 - Response.error (Logged HTTPError if bad HTTP Status)1597 - Response.raise\_for\_status() (Raises stored HTTPError)159815990.2.2 (2011-02-14)1600------------------16011602- Still handles request in the event of an HTTPError. (Issue \#2)1603- Eventlet and Gevent Monkeypatch support.1604- Cookie Support (Issue \#1)160516060.2.1 (2011-02-14)1607------------------16081609- Added file attribute to POST and PUT requests for multipart-encode1610 file uploads.1611- Added Request.url attribute for context and redirects161216130.2.0 (2011-02-14)1614------------------16151616- Birth!161716180.0.1 (2011-02-13)1619------------------16201621- Frustration1622- Conception1623
deleted:HISTORY.rst-1527 removed
1.. :changelog:23Release History4---------------56dev7+++89**Improvements**1011**Bugfixes**1213**Dependencies**1415- We now support idna v2.6.16172.18.3 (2017-08-02)18+++++++++++++++++++1920**Improvements**2122- Running ``$ python -m requests.help`` now includes the installed version of idna.2324**Bugfixes**2526- Fixed issue where Requests would raise ``ConnectionError`` instead of27 ``SSLError`` when encountering SSL problems when using urllib3 v1.22.28292.18.2 (2017-07-25)30+++++++++++++++++++3132**Bugfixes**3334- ``requests.help`` no longer fails on Python 2.6 due to the absence of35 ``ssl.OPENSSL_VERSION_NUMBER``.3637**Dependencies**3839- We now support urllib3 v1.22.40412.18.1 (2017-06-14)42+++++++++++++++++++4344**Bugfixes**4546- Fix an error in the packaging whereby the *.whl contained incorrect data that47 regressed the fix in v2.17.3.48492.18.0 (2017-06-14)50+++++++++++++++++++5152**Improvements**5354- ``Response`` is now a context manager, so can be used directly in a ``with`` statement55 without first having to be wrapped by ``contextlib.closing()``.5657**Bugfixes**5859- Resolve installation failure if multiprocessing is not available60- Resolve tests crash if multiprocessing is not able to determine the number of CPU cores61- Resolve error swallowing in utils set_environ generator6263642.17.3 (2017-05-29)65+++++++++++++++++++6667**Improvements**6869- Improved ``packages`` namespace identity support, for monkeypatching libraries.7071722.17.2 (2017-05-29)73+++++++++++++++++++7475**Improvements**7677- Improved ``packages`` namespace identity support, for monkeypatching libraries.7879802.17.1 (2017-05-29)81+++++++++++++++++++8283**Improvements**8485- Improved ``packages`` namespace identity support, for monkeypatching libraries.8687882.17.0 (2017-05-29)89+++++++++++++++++++9091**Improvements**9293- Removal of the 301 redirect cache. This improves thread-safety.9495962.16.5 (2017-05-28)97+++++++++++++++++++9899- Improvements to ``$ python -m requests.help``.1001012.16.4 (2017-05-27)102+++++++++++++++++++103104- Introduction of the ``$ python -m requests.help`` command, for debugging with maintainers!1051062.16.3 (2017-05-27)107+++++++++++++++++++108109- Further restored the ``requests.packages`` namespace for compatibility reasons.1101112.16.2 (2017-05-27)112+++++++++++++++++++113114- Further restored the ``requests.packages`` namespace for compatibility reasons.115116No code modification (noted below) should be neccessary any longer.1171182.16.1 (2017-05-27)119+++++++++++++++++++120121- Restored the ``requests.packages`` namespace for compatibility reasons.122- Bugfix for ``urllib3`` version parsing.123124**Note**: code that was written to import against the ``requests.packages``125namespace previously will have to import code that rests at this module-level126now.127128For example::129130 from requests.packages.urllib3.poolmanager import PoolManager131132Will need to be re-written to be::133134 from requests.packages import urllib3135 urllib3.poolmanager.PoolManager136137Or, even better::138139 from urllib3.poolmanager import PoolManager1401412.16.0 (2017-05-26)142+++++++++++++++++++143144- Unvendor ALL the things!1451462.15.1 (2017-05-26)147+++++++++++++++++++148149- Everyone makes mistakes.1501512.15.0 (2017-05-26)152+++++++++++++++++++153154**Improvements**155156- Introduction of the ``Response.next`` property, for getting the next157 ``PreparedResponse`` from a redirect chain (when ``allow_redirects=False``).158- Internal refactoring of ``__version__`` module.159160**Bugfixes**161162- Restored once-optional parameter for ``requests.utils.get_environ_proxies()``.1631642.14.2 (2017-05-10)165+++++++++++++++++++166167**Bugfixes**168169- Changed a less-than to an equal-to and an or in the dependency markers to170 widen compatibility with older setuptools releases.1711722.14.1 (2017-05-09)173+++++++++++++++++++174175**Bugfixes**176177- Changed the dependency markers to widen compatibility with older pip178 releases.1791802.14.0 (2017-05-09)181+++++++++++++++++++182183**Improvements**184185- It is now possible to pass ``no_proxy`` as a key to the ``proxies``186 dictionary to provide handling similar to the ``NO_PROXY`` environment187 variable.188- When users provide invalid paths to certificate bundle files or directories189 Requests now raises ``IOError``, rather than failing at the time of the HTTPS190 request with a fairly inscrutable certificate validation error.191- The behavior of ``SessionRedirectMixin`` was slightly altered.192 ``resolve_redirects`` will now detect a redirect by calling193 ``get_redirect_target(response)`` instead of directly194 querying ``Response.is_redirect`` and ``Response.headers['location']``.195 Advanced users will be able to process malformed redirects more easily.196- Changed the internal calculation of elapsed request time to have higher197 resolution on Windows.198- Added ``win_inet_pton`` as conditional dependency for the ``[socks]`` extra199 on Windows with Python 2.7.200- Changed the proxy bypass implementation on Windows: the proxy bypass201 check doesn't use forward and reverse DNS requests anymore202- URLs with schemes that begin with ``http`` but are not ``http`` or ``https``203 no longer have their host parts forced to lowercase.204205**Bugfixes**206207- Much improved handling of non-ASCII ``Location`` header values in redirects.208 Fewer ``UnicodeDecodeErrors`` are encountered on Python 2, and Python 3 now209 correctly understands that Latin-1 is unlikely to be the correct encoding.210- If an attempt to ``seek`` file to find out its length fails, we now211 appropriately handle that by aborting our content-length calculations.212- Restricted ``HTTPDigestAuth`` to only respond to auth challenges made on 4XX213 responses, rather than to all auth challenges.214- Fixed some code that was firing ``DeprecationWarning`` on Python 3.6.215- The dismayed person emoticon (``/o\\``) no longer has a big head. I'm sure216 this is what you were all worrying about most.217218219**Miscellaneous**220221- Updated bundled urllib3 to v1.21.1.222- Updated bundled chardet to v3.0.2.223- Updated bundled idna to v2.5.224- Updated bundled certifi to 2017.4.17.2252262.13.0 (2017-01-24)227+++++++++++++++++++228229**Features**230231- Only load the ``idna`` library when we've determined we need it. This will232 save some memory for users.233234**Miscellaneous**235236- Updated bundled urllib3 to 1.20.237- Updated bundled idna to 2.2.2382392.12.5 (2017-01-18)240+++++++++++++++++++241242**Bugfixes**243244- Fixed an issue with JSON encoding detection, specifically detecting245 big-endian UTF-32 with BOM.2462472.12.4 (2016-12-14)248+++++++++++++++++++249250**Bugfixes**251252- Fixed regression from 2.12.2 where non-string types were rejected in the253 basic auth parameters. While support for this behaviour has been readded,254 the behaviour is deprecated and will be removed in the future.2552562.12.3 (2016-12-01)257+++++++++++++++++++258259**Bugfixes**260261- Fixed regression from v2.12.1 for URLs with schemes that begin with "http".262 These URLs have historically been processed as though they were HTTP-schemed263 URLs, and so have had parameters added. This was removed in v2.12.2 in an264 overzealous attempt to resolve problems with IDNA-encoding those URLs. This265 change was reverted: the other fixes for IDNA-encoding have been judged to266 be sufficient to return to the behaviour Requests had before v2.12.0.2672682.12.2 (2016-11-30)269+++++++++++++++++++270271**Bugfixes**272273- Fixed several issues with IDNA-encoding URLs that are technically invalid but274 which are widely accepted. Requests will now attempt to IDNA-encode a URL if275 it can but, if it fails, and the host contains only ASCII characters, it will276 be passed through optimistically. This will allow users to opt-in to using277 IDNA2003 themselves if they want to, and will also allow technically invalid278 but still common hostnames.279- Fixed an issue where URLs with leading whitespace would raise280 ``InvalidSchema`` errors.281- Fixed an issue where some URLs without the HTTP or HTTPS schemes would still282 have HTTP URL preparation applied to them.283- Fixed an issue where Unicode strings could not be used in basic auth.284- Fixed an issue encountered by some Requests plugins where constructing a285 Response object would cause ``Response.content`` to raise an286 ``AttributeError``.2872882.12.1 (2016-11-16)289+++++++++++++++++++290291**Bugfixes**292293- Updated setuptools 'security' extra for the new PyOpenSSL backend in urllib3.294295**Miscellaneous**296297- Updated bundled urllib3 to 1.19.1.2982992.12.0 (2016-11-15)300+++++++++++++++++++301302**Improvements**303304- Updated support for internationalized domain names from IDNA2003 to IDNA2008.305 This updated support is required for several forms of IDNs and is mandatory306 for .de domains.307- Much improved heuristics for guessing content lengths: Requests will no308 longer read an entire ``StringIO`` into memory.309- Much improved logic for recalculating ``Content-Length`` headers for310 ``PreparedRequest`` objects.311- Improved tolerance for file-like objects that have no ``tell`` method but312 do have a ``seek`` method.313- Anything that is a subclass of ``Mapping`` is now treated like a dictionary314 by the ``data=`` keyword argument.315- Requests now tolerates empty passwords in proxy credentials, rather than316 stripping the credentials.317- If a request is made with a file-like object as the body and that request is318 redirected with a 307 or 308 status code, Requests will now attempt to319 rewind the body object so it can be replayed.320321**Bugfixes**322323- When calling ``response.close``, the call to ``close`` will be propagated324 through to non-urllib3 backends.325- Fixed issue where the ``ALL_PROXY`` environment variable would be preferred326 over scheme-specific variables like ``HTTP_PROXY``.327- Fixed issue where non-UTF8 reason phrases got severely mangled by falling328 back to decoding using ISO 8859-1 instead.329- Fixed a bug where Requests would not correctly correlate cookies set when330 using custom Host headers if those Host headers did not use the native331 string type for the platform.332333**Miscellaneous**334335- Updated bundled urllib3 to 1.19.336- Updated bundled certifi certs to 2016.09.26.3373382.11.1 (2016-08-17)339+++++++++++++++++++340341**Bugfixes**342343- Fixed a bug when using ``iter_content`` with ``decode_unicode=True`` for344 streamed bodies would raise ``AttributeError``. This bug was introduced in345 2.11.346- Strip Content-Type and Transfer-Encoding headers from the header block when347 following a redirect that transforms the verb from POST/PUT to GET.3483492.11.0 (2016-08-08)350+++++++++++++++++++351352**Improvements**353354- Added support for the ``ALL_PROXY`` environment variable.355- Reject header values that contain leading whitespace or newline characters to356 reduce risk of header smuggling.357358**Bugfixes**359360- Fixed occasional ``TypeError`` when attempting to decode a JSON response that361 occurred in an error case. Now correctly returns a ``ValueError``.362- Requests would incorrectly ignore a non-CIDR IP address in the ``NO_PROXY``363 environment variables: Requests now treats it as a specific IP.364- Fixed a bug when sending JSON data that could cause us to encounter obscure365 OpenSSL errors in certain network conditions (yes, really).366- Added type checks to ensure that ``iter_content`` only accepts integers and367 ``None`` for chunk sizes.368- Fixed issue where responses whose body had not been fully consumed would have369 the underlying connection closed but not returned to the connection pool,370 which could cause Requests to hang in situations where the ``HTTPAdapter``371 had been configured to use a blocking connection pool.372373**Miscellaneous**374375- Updated bundled urllib3 to 1.16.376- Some previous releases accidentally accepted non-strings as acceptable header values. This release does not.3773782.10.0 (2016-04-29)379+++++++++++++++++++380381**New Features**382383- SOCKS Proxy Support! (requires PySocks; ``$ pip install requests[socks]``)384385**Miscellaneous**386387- Updated bundled urllib3 to 1.15.1.3883892.9.2 (2016-04-29)390++++++++++++++++++391392**Improvements**393394- Change built-in CaseInsensitiveDict (used for headers) to use OrderedDict395 as its underlying datastore.396397**Bugfixes**398399- Don't use redirect_cache if allow_redirects=False400- When passed objects that throw exceptions from ``tell()``, send them via401 chunked transfer encoding instead of failing.402- Raise a ProxyError for proxy related connection issues.4034042.9.1 (2015-12-21)405++++++++++++++++++406407**Bugfixes**408409- Resolve regression introduced in 2.9.0 that made it impossible to send binary410 strings as bodies in Python 3.411- Fixed errors when calculating cookie expiration dates in certain locales.412413**Miscellaneous**414415- Updated bundled urllib3 to 1.13.1.4164172.9.0 (2015-12-15)418++++++++++++++++++419420**Minor Improvements** (Backwards compatible)421422- The ``verify`` keyword argument now supports being passed a path to a423 directory of CA certificates, not just a single-file bundle.424- Warnings are now emitted when sending files opened in text mode.425- Added the 511 Network Authentication Required status code to the status code426 registry.427428**Bugfixes**429430- For file-like objects that are not seeked to the very beginning, we now431 send the content length for the number of bytes we will actually read, rather432 than the total size of the file, allowing partial file uploads.433- When uploading file-like objects, if they are empty or have no obvious434 content length we set ``Transfer-Encoding: chunked`` rather than435 ``Content-Length: 0``.436- We correctly receive the response in buffered mode when uploading chunked437 bodies.438- We now handle being passed a query string as a bytestring on Python 3, by439 decoding it as UTF-8.440- Sessions are now closed in all cases (exceptional and not) when using the441 functional API rather than leaking and waiting for the garbage collector to442 clean them up.443- Correctly handle digest auth headers with a malformed ``qop`` directive that444 contains no token, by treating it the same as if no ``qop`` directive was445 provided at all.446- Minor performance improvements when removing specific cookies by name.447448**Miscellaneous**449450- Updated urllib3 to 1.13.4514522.8.1 (2015-10-13)453++++++++++++++++++454455**Bugfixes**456457- Update certificate bundle to match ``certifi`` 2015.9.6.2's weak certificate458 bundle.459- Fix a bug in 2.8.0 where requests would raise ``ConnectTimeout`` instead of460 ``ConnectionError``461- When using the PreparedRequest flow, requests will now correctly respect the462 ``json`` parameter. Broken in 2.8.0.463- When using the PreparedRequest flow, requests will now correctly handle a464 Unicode-string method name on Python 2. Broken in 2.8.0.4654662.8.0 (2015-10-05)467++++++++++++++++++468469**Minor Improvements** (Backwards Compatible)470471- Requests now supports per-host proxies. This allows the ``proxies``472 dictionary to have entries of the form473 ``{'<scheme>://<hostname>': '<proxy>'}``. Host-specific proxies will be used474 in preference to the previously-supported scheme-specific ones, but the475 previous syntax will continue to work.476- ``Response.raise_for_status`` now prints the URL that failed as part of the477 exception message.478- ``requests.utils.get_netrc_auth`` now takes an ``raise_errors`` kwarg,479 defaulting to ``False``. When ``True``, errors parsing ``.netrc`` files cause480 exceptions to be thrown.481- Change to bundled projects import logic to make it easier to unbundle482 requests downstream.483- Changed the default User-Agent string to avoid leaking data on Linux: now484 contains only the requests version.485486**Bugfixes**487488- The ``json`` parameter to ``post()`` and friends will now only be used if489 neither ``data`` nor ``files`` are present, consistent with the490 documentation.491- We now ignore empty fields in the ``NO_PROXY`` environment variable.492- Fixed problem where ``httplib.BadStatusLine`` would get raised if combining493 ``stream=True`` with ``contextlib.closing``.494- Prevented bugs where we would attempt to return the same connection back to495 the connection pool twice when sending a Chunked body.496- Miscellaneous minor internal changes.497- Digest Auth support is now thread safe.498499**Updates**500501- Updated urllib3 to 1.12.5025032.7.0 (2015-05-03)504++++++++++++++++++505506This is the first release that follows our new release process. For more, see507`our documentation508<http://docs.python-requests.org/en/latest/community/release-process/>`_.509510**Bugfixes**511512- Updated urllib3 to 1.10.4, resolving several bugs involving chunked transfer513 encoding and response framing.5145152.6.2 (2015-04-23)516++++++++++++++++++517518**Bugfixes**519520- Fix regression where compressed data that was sent as chunked data was not521 properly decompressed. (#2561)5225232.6.1 (2015-04-22)524++++++++++++++++++525526**Bugfixes**527528- Remove VendorAlias import machinery introduced in v2.5.2.529530- Simplify the PreparedRequest.prepare API: We no longer require the user to531 pass an empty list to the hooks keyword argument. (c.f. #2552)532533- Resolve redirects now receives and forwards all of the original arguments to534 the adapter. (#2503)535536- Handle UnicodeDecodeErrors when trying to deal with a unicode URL that537 cannot be encoded in ASCII. (#2540)538539- Populate the parsed path of the URI field when performing Digest540 Authentication. (#2426)541542- Copy a PreparedRequest's CookieJar more reliably when it is not an instance543 of RequestsCookieJar. (#2527)5445452.6.0 (2015-03-14)546++++++++++++++++++547548**Bugfixes**549550- CVE-2015-2296: Fix handling of cookies on redirect. Previously a cookie551 without a host value set would use the hostname for the redirected URL552 exposing requests users to session fixation attacks and potentially cookie553 stealing. This was disclosed privately by Matthew Daley of554 `BugFuzz <https://bugfuzz.com>`_. This affects all versions of requests from555 v2.1.0 to v2.5.3 (inclusive on both ends).556557- Fix error when requests is an ``install_requires`` dependency and ``python558 setup.py test`` is run. (#2462)559560- Fix error when urllib3 is unbundled and requests continues to use the561 vendored import location.562563- Include fixes to ``urllib3``'s header handling.564565- Requests' handling of unvendored dependencies is now more restrictive.566567**Features and Improvements**568569- Support bytearrays when passed as parameters in the ``files`` argument.570 (#2468)571572- Avoid data duplication when creating a request with ``str``, ``bytes``, or573 ``bytearray`` input to the ``files`` argument.5745752.5.3 (2015-02-24)576++++++++++++++++++577578**Bugfixes**579580- Revert changes to our vendored certificate bundle. For more context see581 (#2455, #2456, and http://bugs.python.org/issue23476)5825832.5.2 (2015-02-23)584++++++++++++++++++585586**Features and Improvements**587588- Add sha256 fingerprint support. (`shazow/urllib3#540`_)589590- Improve the performance of headers. (`shazow/urllib3#544`_)591592**Bugfixes**593594- Copy pip's import machinery. When downstream redistributors remove595 requests.packages.urllib3 the import machinery will continue to let those596 same symbols work. Example usage in requests' documentation and 3rd-party597 libraries relying on the vendored copies of urllib3 will work without having598 to fallback to the system urllib3.599600- Attempt to quote parts of the URL on redirect if unquoting and then quoting601 fails. (#2356)602603- Fix filename type check for multipart form-data uploads. (#2411)604605- Properly handle the case where a server issuing digest authentication606 challenges provides both auth and auth-int qop-values. (#2408)607608- Fix a socket leak. (`shazow/urllib3#549`_)609610- Fix multiple ``Set-Cookie`` headers properly. (`shazow/urllib3#534`_)611612- Disable the built-in hostname verification. (`shazow/urllib3#526`_)613614- Fix the behaviour of decoding an exhausted stream. (`shazow/urllib3#535`_)615616**Security**617618- Pulled in an updated ``cacert.pem``.619620- Drop RC4 from the default cipher list. (`shazow/urllib3#551`_)621622.. _shazow/urllib3#551: https://github.com/shazow/urllib3/pull/551623.. _shazow/urllib3#549: https://github.com/shazow/urllib3/pull/549624.. _shazow/urllib3#544: https://github.com/shazow/urllib3/pull/544625.. _shazow/urllib3#540: https://github.com/shazow/urllib3/pull/540626.. _shazow/urllib3#535: https://github.com/shazow/urllib3/pull/535627.. _shazow/urllib3#534: https://github.com/shazow/urllib3/pull/534628.. _shazow/urllib3#526: https://github.com/shazow/urllib3/pull/5266296302.5.1 (2014-12-23)631++++++++++++++++++632633**Behavioural Changes**634635- Only catch HTTPErrors in raise_for_status (#2382)636637**Bugfixes**638639- Handle LocationParseError from urllib3 (#2344)640- Handle file-like object filenames that are not strings (#2379)641- Unbreak HTTPDigestAuth handler. Allow new nonces to be negotiated (#2389)6426432.5.0 (2014-12-01)644++++++++++++++++++645646**Improvements**647648- Allow usage of urllib3's Retry object with HTTPAdapters (#2216)649- The ``iter_lines`` method on a response now accepts a delimiter with which650 to split the content (#2295)651652**Behavioural Changes**653654- Add deprecation warnings to functions in requests.utils that will be removed655 in 3.0 (#2309)656- Sessions used by the functional API are always closed (#2326)657- Restrict requests to HTTP/1.1 and HTTP/1.0 (stop accepting HTTP/0.9) (#2323)658659**Bugfixes**660661- Only parse the URL once (#2353)662- Allow Content-Length header to always be overridden (#2332)663- Properly handle files in HTTPDigestAuth (#2333)664- Cap redirect_cache size to prevent memory abuse (#2299)665- Fix HTTPDigestAuth handling of redirects after authenticating successfully666 (#2253)667- Fix crash with custom method parameter to Session.request (#2317)668- Fix how Link headers are parsed using the regular expression library (#2271)669670**Documentation**671672- Add more references for interlinking (#2348)673- Update CSS for theme (#2290)674- Update width of buttons and sidebar (#2289)675- Replace references of Gittip with Gratipay (#2282)676- Add link to changelog in sidebar (#2273)6776782.4.3 (2014-10-06)679++++++++++++++++++680681**Bugfixes**682683- Unicode URL improvements for Python 2.684- Re-order JSON param for backwards compat.685- Automatically defrag authentication schemes from host/pass URIs. (`#2249 <https://github.com/requests/requests/issues/2249>`_)6866876882.4.2 (2014-10-05)689++++++++++++++++++690691**Improvements**692693- FINALLY! Add json parameter for uploads! (`#2258 <https://github.com/requests/requests/pull/2258>`_)694- Support for bytestring URLs on Python 3.x (`#2238 <https://github.com/requests/requests/pull/2238>`_)695696**Bugfixes**697698- Avoid getting stuck in a loop (`#2244 <https://github.com/requests/requests/pull/2244>`_)699- Multiple calls to iter* fail with unhelpful error. (`#2240 <https://github.com/requests/requests/issues/2240>`_, `#2241 <https://github.com/requests/requests/issues/2241>`_)700701**Documentation**702703- Correct redirection introduction (`#2245 <https://github.com/requests/requests/pull/2245/>`_)704- Added example of how to send multiple files in one request. (`#2227 <https://github.com/requests/requests/pull/2227/>`_)705- Clarify how to pass a custom set of CAs (`#2248 <https://github.com/requests/requests/pull/2248/>`_)7067077087092.4.1 (2014-09-09)710++++++++++++++++++711712- Now has a "security" package extras set, ``$ pip install requests[security]``713- Requests will now use Certifi if it is available.714- Capture and re-raise urllib3 ProtocolError715- Bugfix for responses that attempt to redirect to themselves forever (wtf?).7167177182.4.0 (2014-08-29)719++++++++++++++++++720721**Behavioral Changes**722723- ``Connection: keep-alive`` header is now sent automatically.724725**Improvements**726727- Support for connect timeouts! Timeout now accepts a tuple (connect, read) which is used to set individual connect and read timeouts.728- Allow copying of PreparedRequests without headers/cookies.729- Updated bundled urllib3 version.730- Refactored settings loading from environment -- new `Session.merge_environment_settings`.731- Handle socket errors in iter_content.7327337342.3.0 (2014-05-16)735++++++++++++++++++736737**API Changes**738739- New ``Response`` property ``is_redirect``, which is true when the740 library could have processed this response as a redirection (whether741 or not it actually did).742- The ``timeout`` parameter now affects requests with both ``stream=True`` and743 ``stream=False`` equally.744- The change in v2.0.0 to mandate explicit proxy schemes has been reverted.745 Proxy schemes now default to ``http://``.746- The ``CaseInsensitiveDict`` used for HTTP headers now behaves like a normal747 dictionary when references as string or viewed in the interpreter.748749**Bugfixes**750751- No longer expose Authorization or Proxy-Authorization headers on redirect.752 Fix CVE-2014-1829 and CVE-2014-1830 respectively.753- Authorization is re-evaluated each redirect.754- On redirect, pass url as native strings.755- Fall-back to autodetected encoding for JSON when Unicode detection fails.756- Headers set to ``None`` on the ``Session`` are now correctly not sent.757- Correctly honor ``decode_unicode`` even if it wasn't used earlier in the same758 response.759- Stop advertising ``compress`` as a supported Content-Encoding.760- The ``Response.history`` parameter is now always a list.761- Many, many ``urllib3`` bugfixes.7627632.2.1 (2014-01-23)764++++++++++++++++++765766**Bugfixes**767768- Fixes incorrect parsing of proxy credentials that contain a literal or encoded '#' character.769- Assorted urllib3 fixes.7707712.2.0 (2014-01-09)772++++++++++++++++++773774**API Changes**775776- New exception: ``ContentDecodingError``. Raised instead of ``urllib3``777 ``DecodeError`` exceptions.778779**Bugfixes**780781- Avoid many many exceptions from the buggy implementation of ``proxy_bypass`` on OS X in Python 2.6.782- Avoid crashing when attempting to get authentication credentials from ~/.netrc when running as a user without a home directory.783- Use the correct pool size for pools of connections to proxies.784- Fix iteration of ``CookieJar`` objects.785- Ensure that cookies are persisted over redirect.786- Switch back to using chardet, since it has merged with charade.7877882.1.0 (2013-12-05)789++++++++++++++++++790791- Updated CA Bundle, of course.792- Cookies set on individual Requests through a ``Session`` (e.g. via ``Session.get()``) are no longer persisted to the ``Session``.793- Clean up connections when we hit problems during chunked upload, rather than leaking them.794- Return connections to the pool when a chunked upload is successful, rather than leaking it.795- Match the HTTPbis recommendation for HTTP 301 redirects.796- Prevent hanging when using streaming uploads and Digest Auth when a 401 is received.797- Values of headers set by Requests are now always the native string type.798- Fix previously broken SNI support.799- Fix accessing HTTP proxies using proxy authentication.800- Unencode HTTP Basic usernames and passwords extracted from URLs.801- Support for IP address ranges for no_proxy environment variable802- Parse headers correctly when users override the default ``Host:`` header.803- Avoid munging the URL in case of case-sensitive servers.804- Looser URL handling for non-HTTP/HTTPS urls.805- Accept unicode methods in Python 2.6 and 2.7.806- More resilient cookie handling.807- Make ``Response`` objects pickleable.808- Actually added MD5-sess to Digest Auth instead of pretending to like last time.809- Updated internal urllib3.810- Fixed @Lukasa's lack of taste.8118122.0.1 (2013-10-24)813++++++++++++++++++814815- Updated included CA Bundle with new mistrusts and automated process for the future816- Added MD5-sess to Digest Auth817- Accept per-file headers in multipart file POST messages.818- Fixed: Don't send the full URL on CONNECT messages.819- Fixed: Correctly lowercase a redirect scheme.820- Fixed: Cookies not persisted when set via functional API.821- Fixed: Translate urllib3 ProxyError into a requests ProxyError derived from ConnectionError.822- Updated internal urllib3 and chardet.8238242.0.0 (2013-09-24)825++++++++++++++++++826827**API Changes:**828829- Keys in the Headers dictionary are now native strings on all Python versions,830 i.e. bytestrings on Python 2, unicode on Python 3.831- Proxy URLs now *must* have an explicit scheme. A ``MissingSchema`` exception832 will be raised if they don't.833- Timeouts now apply to read time if ``Stream=False``.834- ``RequestException`` is now a subclass of ``IOError``, not ``RuntimeError``.835- Added new method to ``PreparedRequest`` objects: ``PreparedRequest.copy()``.836- Added new method to ``Session`` objects: ``Session.update_request()``. This837 method updates a ``Request`` object with the data (e.g. cookies) stored on838 the ``Session``.839- Added new method to ``Session`` objects: ``Session.prepare_request()``. This840 method updates and prepares a ``Request`` object, and returns the841 corresponding ``PreparedRequest`` object.842- Added new method to ``HTTPAdapter`` objects: ``HTTPAdapter.proxy_headers()``.843 This should not be called directly, but improves the subclass interface.844- ``httplib.IncompleteRead`` exceptions caused by incorrect chunked encoding845 will now raise a Requests ``ChunkedEncodingError`` instead.846- Invalid percent-escape sequences now cause a Requests ``InvalidURL``847 exception to be raised.848- HTTP 208 no longer uses reason phrase ``"im_used"``. Correctly uses849 ``"already_reported"``.850- HTTP 226 reason added (``"im_used"``).851852**Bugfixes:**853854- Vastly improved proxy support, including the CONNECT verb. Special thanks to855 the many contributors who worked towards this improvement.856- Cookies are now properly managed when 401 authentication responses are857 received.858- Chunked encoding fixes.859- Support for mixed case schemes.860- Better handling of streaming downloads.861- Retrieve environment proxies from more locations.862- Minor cookies fixes.863- Improved redirect behaviour.864- Improved streaming behaviour, particularly for compressed data.865- Miscellaneous small Python 3 text encoding bugs.866- ``.netrc`` no longer overrides explicit auth.867- Cookies set by hooks are now correctly persisted on Sessions.868- Fix problem with cookies that specify port numbers in their host field.869- ``BytesIO`` can be used to perform streaming uploads.870- More generous parsing of the ``no_proxy`` environment variable.871- Non-string objects can be passed in data values alongside files.8728731.2.3 (2013-05-25)874++++++++++++++++++875876- Simple packaging fix8778788791.2.2 (2013-05-23)880++++++++++++++++++881882- Simple packaging fix8838848851.2.1 (2013-05-20)886++++++++++++++++++887888- 301 and 302 redirects now change the verb to GET for all verbs, not just889 POST, improving browser compatibility.890- Python 3.3.2 compatibility891- Always percent-encode location headers892- Fix connection adapter matching to be most-specific first893- new argument to the default connection adapter for passing a block argument894- prevent a KeyError when there's no link headers8958961.2.0 (2013-03-31)897++++++++++++++++++898899- Fixed cookies on sessions and on requests900- Significantly change how hooks are dispatched - hooks now receive all the901 arguments specified by the user when making a request so hooks can make a902 secondary request with the same parameters. This is especially necessary for903 authentication handler authors904- certifi support was removed905- Fixed bug where using OAuth 1 with body ``signature_type`` sent no data906- Major proxy work thanks to @Lukasa including parsing of proxy authentication907 from the proxy url908- Fix DigestAuth handling too many 401s909- Update vendored urllib3 to include SSL bug fixes910- Allow keyword arguments to be passed to ``json.loads()`` via the911 ``Response.json()`` method912- Don't send ``Content-Length`` header by default on ``GET`` or ``HEAD``913 requests914- Add ``elapsed`` attribute to ``Response`` objects to time how long a request915 took.916- Fix ``RequestsCookieJar``917- Sessions and Adapters are now picklable, i.e., can be used with the918 multiprocessing library919- Update charade to version 1.0.3920921The change in how hooks are dispatched will likely cause a great deal of922issues.9239241.1.0 (2013-01-10)925++++++++++++++++++926927- CHUNKED REQUESTS928- Support for iterable response bodies929- Assume servers persist redirect params930- Allow explicit content types to be specified for file data931- Make merge_kwargs case-insensitive when looking up keys9329331.0.3 (2012-12-18)934++++++++++++++++++935936- Fix file upload encoding bug937- Fix cookie behavior9389391.0.2 (2012-12-17)940++++++++++++++++++941942- Proxy fix for HTTPAdapter.9439441.0.1 (2012-12-17)945++++++++++++++++++946947- Cert verification exception bug.948- Proxy fix for HTTPAdapter.9499501.0.0 (2012-12-17)951++++++++++++++++++952953- Massive Refactor and Simplification954- Switch to Apache 2.0 license955- Swappable Connection Adapters956- Mountable Connection Adapters957- Mutable ProcessedRequest chain958- /s/prefetch/stream959- Removal of all configuration960- Standard library logging961- Make Response.json() callable, not property.962- Usage of new charade project, which provides python 2 and 3 simultaneous chardet.963- Removal of all hooks except 'response'964- Removal of all authentication helpers (OAuth, Kerberos)965966This is not a backwards compatible change.9679680.14.2 (2012-10-27)969+++++++++++++++++++970971- Improved mime-compatible JSON handling972- Proxy fixes973- Path hack fixes974- Case-Insensitive Content-Encoding headers975- Support for CJK parameters in form posts9769779780.14.1 (2012-10-01)979+++++++++++++++++++980981- Python 3.3 Compatibility982- Simply default accept-encoding983- Bugfixes9849859860.14.0 (2012-09-02)987++++++++++++++++++++988989- No more iter_content errors if already downloaded.9909910.13.9 (2012-08-25)992+++++++++++++++++++993994- Fix for OAuth + POSTs995- Remove exception eating from dispatch_hook996- General bugfixes9979980.13.8 (2012-08-21)999+++++++++++++++++++10001001- Incredible Link header support :)100210030.13.7 (2012-08-19)1004+++++++++++++++++++10051006- Support for (key, value) lists everywhere.1007- Digest Authentication improvements.1008- Ensure proxy exclusions work properly.1009- Clearer UnicodeError exceptions.1010- Automatic casting of URLs to strings (fURL and such)1011- Bugfixes.101210130.13.6 (2012-08-06)1014+++++++++++++++++++10151016- Long awaited fix for hanging connections!101710180.13.5 (2012-07-27)1019+++++++++++++++++++10201021- Packaging fix102210230.13.4 (2012-07-27)1024+++++++++++++++++++10251026- GSSAPI/Kerberos authentication!1027- App Engine 2.7 Fixes!1028- Fix leaking connections (from urllib3 update)1029- OAuthlib path hack fix1030- OAuthlib URL parameters fix.103110320.13.3 (2012-07-12)1033+++++++++++++++++++10341035- Use simplejson if available.1036- Do not hide SSLErrors behind Timeouts.1037- Fixed param handling with urls containing fragments.1038- Significantly improved information in User Agent.1039- client certificates are ignored when verify=False104010410.13.2 (2012-06-28)1042+++++++++++++++++++10431044- Zero dependencies (once again)!1045- New: Response.reason1046- Sign querystring parameters in OAuth 1.01047- Client certificates no longer ignored when verify=False1048- Add openSUSE certificate support104910500.13.1 (2012-06-07)1051+++++++++++++++++++10521053- Allow passing a file or file-like object as data.1054- Allow hooks to return responses that indicate errors.1055- Fix Response.text and Response.json for body-less responses.105610570.13.0 (2012-05-29)1058+++++++++++++++++++10591060- Removal of Requests.async in favor of `grequests <https://github.com/kennethreitz/grequests>`_1061- Allow disabling of cookie persistence.1062- New implementation of safe_mode1063- cookies.get now supports default argument1064- Session cookies not saved when Session.request is called with return_response=False1065- Env: no_proxy support.1066- RequestsCookieJar improvements.1067- Various bug fixes.106810690.12.1 (2012-05-08)1070+++++++++++++++++++10711072- New ``Response.json`` property.1073- Ability to add string file uploads.1074- Fix out-of-range issue with iter_lines.1075- Fix iter_content default size.1076- Fix POST redirects containing files.107710780.12.0 (2012-05-02)1079+++++++++++++++++++10801081- EXPERIMENTAL OAUTH SUPPORT!1082- Proper CookieJar-backed cookies interface with awesome dict-like interface.1083- Speed fix for non-iterated content chunks.1084- Move ``pre_request`` to a more usable place.1085- New ``pre_send`` hook.1086- Lazily encode data, params, files.1087- Load system Certificate Bundle if ``certify`` isn't available.1088- Cleanups, fixes.108910900.11.2 (2012-04-22)1091+++++++++++++++++++10921093- Attempt to use the OS's certificate bundle if ``certifi`` isn't available.1094- Infinite digest auth redirect fix.1095- Multi-part file upload improvements.1096- Fix decoding of invalid %encodings in URLs.1097- If there is no content in a response don't throw an error the second time that content is attempted to be read.1098- Upload data on redirects.109911000.11.1 (2012-03-30)1101+++++++++++++++++++11021103* POST redirects now break RFC to do what browsers do: Follow up with a GET.1104* New ``strict_mode`` configuration to disable new redirect behavior.1105110611070.11.0 (2012-03-14)1108+++++++++++++++++++11091110* Private SSL Certificate support1111* Remove select.poll from Gevent monkeypatching1112* Remove redundant generator for chunked transfer encoding1113* Fix: Response.ok raises Timeout Exception in safe_mode111411150.10.8 (2012-03-09)1116+++++++++++++++++++11171118* Generate chunked ValueError fix1119* Proxy configuration by environment variables1120* Simplification of iter_lines.1121* New `trust_env` configuration for disabling system/environment hints.1122* Suppress cookie errors.112311240.10.7 (2012-03-07)1125+++++++++++++++++++11261127* `encode_uri` = False112811290.10.6 (2012-02-25)1130+++++++++++++++++++11311132* Allow '=' in cookies.113311340.10.5 (2012-02-25)1135+++++++++++++++++++11361137* Response body with 0 content-length fix.1138* New async.imap.1139* Don't fail on netrc.1140114111420.10.4 (2012-02-20)1143+++++++++++++++++++11441145* Honor netrc.114611470.10.3 (2012-02-20)1148+++++++++++++++++++11491150* HEAD requests don't follow redirects anymore.1151* raise_for_status() doesn't raise for 3xx anymore.1152* Make Session objects picklable.1153* ValueError for invalid schema URLs.115411550.10.2 (2012-01-15)1156+++++++++++++++++++11571158* Vastly improved URL quoting.1159* Additional allowed cookie key values.1160* Attempted fix for "Too many open files" Error1161* Replace unicode errors on first pass, no need for second pass.1162* Append '/' to bare-domain urls before query insertion.1163* Exceptions now inherit from RuntimeError.1164* Binary uploads + auth fix.1165* Bugfixes.1166116711680.10.1 (2012-01-23)1169+++++++++++++++++++11701171* PYTHON 3 SUPPORT!1172* Dropped 2.5 Support. (*Backwards Incompatible*)117311740.10.0 (2012-01-21)1175+++++++++++++++++++11761177* ``Response.content`` is now bytes-only. (*Backwards Incompatible*)1178* New ``Response.text`` is unicode-only.1179* If no ``Response.encoding`` is specified and ``chardet`` is available, ``Response.text`` will guess an encoding.1180* Default to ISO-8859-1 (Western) encoding for "text" subtypes.1181* Removal of `decode_unicode`. (*Backwards Incompatible*)1182* New multiple-hooks system.1183* New ``Response.register_hook`` for registering hooks within the pipeline.1184* ``Response.url`` is now Unicode.118511860.9.3 (2012-01-18)1187++++++++++++++++++11881189* SSL verify=False bugfix (apparent on windows machines).119011910.9.2 (2012-01-18)1192++++++++++++++++++11931194* Asynchronous async.send method.1195* Support for proper chunk streams with boundaries.1196* session argument for Session classes.1197* Print entire hook tracebacks, not just exception instance.1198* Fix response.iter_lines from pending next line.1199* Fix but in HTTP-digest auth w/ URI having query strings.1200* Fix in Event Hooks section.1201* Urllib3 update.1202120312040.9.1 (2012-01-06)1205++++++++++++++++++12061207* danger_mode for automatic Response.raise_for_status()1208* Response.iter_lines refactor120912100.9.0 (2011-12-28)1211++++++++++++++++++12121213* verify ssl is default.1214121512160.8.9 (2011-12-28)1217++++++++++++++++++12181219* Packaging fix.1220122112220.8.8 (2011-12-28)1223++++++++++++++++++12241225* SSL CERT VERIFICATION!1226* Release of Cerifi: Mozilla's cert list.1227* New 'verify' argument for SSL requests.1228* Urllib3 update.122912300.8.7 (2011-12-24)1231++++++++++++++++++12321233* iter_lines last-line truncation fix1234* Force safe_mode for async requests1235* Handle safe_mode exceptions more consistently1236* Fix iteration on null responses in safe_mode123712380.8.6 (2011-12-18)1239++++++++++++++++++12401241* Socket timeout fixes.1242* Proxy Authorization support.124312440.8.5 (2011-12-14)1245++++++++++++++++++12461247* Response.iter_lines!124812490.8.4 (2011-12-11)1250++++++++++++++++++12511252* Prefetch bugfix.1253* Added license to installed version.125412550.8.3 (2011-11-27)1256++++++++++++++++++12571258* Converted auth system to use simpler callable objects.1259* New session parameter to API methods.1260* Display full URL while logging.126112620.8.2 (2011-11-19)1263++++++++++++++++++12641265* New Unicode decoding system, based on over-ridable `Response.encoding`.1266* Proper URL slash-quote handling.1267* Cookies with ``[``, ``]``, and ``_`` allowed.126812690.8.1 (2011-11-15)1270++++++++++++++++++12711272* URL Request path fix1273* Proxy fix.1274* Timeouts fix.127512760.8.0 (2011-11-13)1277++++++++++++++++++12781279* Keep-alive support!1280* Complete removal of Urllib21281* Complete removal of Poster1282* Complete removal of CookieJars1283* New ConnectionError raising1284* Safe_mode for error catching1285* prefetch parameter for request methods1286* OPTION method1287* Async pool size throttling1288* File uploads send real names1289* Vendored in urllib3129012910.7.6 (2011-11-07)1292++++++++++++++++++12931294* Digest authentication bugfix (attach query data to path)129512960.7.5 (2011-11-04)1297++++++++++++++++++12981299* Response.content = None if there was an invalid response.1300* Redirection auth handling.130113020.7.4 (2011-10-26)1303++++++++++++++++++13041305* Session Hooks fix.130613070.7.3 (2011-10-23)1308++++++++++++++++++13091310* Digest Auth fix.1311131213130.7.2 (2011-10-23)1314++++++++++++++++++13151316* PATCH Fix.1317131813190.7.1 (2011-10-23)1320++++++++++++++++++13211322* Move away from urllib2 authentication handling.1323* Fully Remove AuthManager, AuthObject, &c.1324* New tuple-based auth system with handler callbacks.1325132613270.7.0 (2011-10-22)1328++++++++++++++++++13291330* Sessions are now the primary interface.1331* Deprecated InvalidMethodException.1332* PATCH fix.1333* New config system (no more global settings).1334133513360.6.6 (2011-10-19)1337++++++++++++++++++13381339* Session parameter bugfix (params merging).1340134113420.6.5 (2011-10-18)1343++++++++++++++++++13441345* Offline (fast) test suite.1346* Session dictionary argument merging.1347134813490.6.4 (2011-10-13)1350++++++++++++++++++13511352* Automatic decoding of unicode, based on HTTP Headers.1353* New ``decode_unicode`` setting.1354* Removal of ``r.read/close`` methods.1355* New ``r.faw`` interface for advanced response usage.*1356* Automatic expansion of parameterized headers.1357135813590.6.3 (2011-10-13)1360++++++++++++++++++13611362* Beautiful ``requests.async`` module, for making async requests w/ gevent.1363136413650.6.2 (2011-10-09)1366++++++++++++++++++13671368* GET/HEAD obeys allow_redirects=False.1369137013710.6.1 (2011-08-20)1372++++++++++++++++++13731374* Enhanced status codes experience ``\o/``1375* Set a maximum number of redirects (``settings.max_redirects``)1376* Full Unicode URL support1377* Support for protocol-less redirects.1378* Allow for arbitrary request types.1379* Bugfixes1380138113820.6.0 (2011-08-17)1383++++++++++++++++++13841385* New callback hook system1386* New persistent sessions object and context manager1387* Transparent Dict-cookie handling1388* Status code reference object1389* Removed Response.cached1390* Added Response.request1391* All args are kwargs1392* Relative redirect support1393* HTTPError handling improvements1394* Improved https testing1395* Bugfixes1396139713980.5.1 (2011-07-23)1399++++++++++++++++++14001401* International Domain Name Support!1402* Access headers without fetching entire body (``read()``)1403* Use lists as dicts for parameters1404* Add Forced Basic Authentication1405* Forced Basic is default authentication type1406* ``python-requests.org`` default User-Agent header1407* CaseInsensitiveDict lower-case caching1408* Response.history bugfix1409141014110.5.0 (2011-06-21)1412++++++++++++++++++14131414* PATCH Support1415* Support for Proxies1416* HTTPBin Test Suite1417* Redirect Fixes1418* settings.verbose stream writing1419* Querystrings for all methods1420* URLErrors (Connection Refused, Timeout, Invalid URLs) are treated as explicitly raised1421 ``r.requests.get('hwe://blah'); r.raise_for_status()``1422142314240.4.1 (2011-05-22)1425++++++++++++++++++14261427* Improved Redirection Handling1428* New 'allow_redirects' param for following non-GET/HEAD Redirects1429* Settings module refactoring1430143114320.4.0 (2011-05-15)1433++++++++++++++++++14341435* Response.history: list of redirected responses1436* Case-Insensitive Header Dictionaries!1437* Unicode URLs1438143914400.3.4 (2011-05-14)1441++++++++++++++++++14421443* Urllib2 HTTPAuthentication Recursion fix (Basic/Digest)1444* Internal Refactor1445* Bytes data upload Bugfix14461447144814490.3.3 (2011-05-12)1450++++++++++++++++++14511452* Request timeouts1453* Unicode url-encoded data1454* Settings context manager and module1455145614570.3.2 (2011-04-15)1458++++++++++++++++++14591460* Automatic Decompression of GZip Encoded Content1461* AutoAuth Support for Tupled HTTP Auth1462146314640.3.1 (2011-04-01)1465++++++++++++++++++14661467* Cookie Changes1468* Response.read()1469* Poster fix1470147114720.3.0 (2011-02-25)1473++++++++++++++++++14741475* Automatic Authentication API Change1476* Smarter Query URL Parameterization1477* Allow file uploads and POST data together1478* New Authentication Manager System1479 - Simpler Basic HTTP System1480 - Supports all build-in urllib2 Auths1481 - Allows for custom Auth Handlers1482148314840.2.4 (2011-02-19)1485++++++++++++++++++14861487* Python 2.5 Support1488* PyPy-c v1.4 Support1489* Auto-Authentication tests1490* Improved Request object constructor149114920.2.3 (2011-02-15)1493++++++++++++++++++14941495* New HTTPHandling Methods1496 - Response.__nonzero__ (false if bad HTTP Status)1497 - Response.ok (True if expected HTTP Status)1498 - Response.error (Logged HTTPError if bad HTTP Status)1499 - Response.raise_for_status() (Raises stored HTTPError)1500150115020.2.2 (2011-02-14)1503++++++++++++++++++15041505* Still handles request in the event of an HTTPError. (Issue #2)1506* Eventlet and Gevent Monkeypatch support.1507* Cookie Support (Issue #1)1508150915100.2.1 (2011-02-14)1511++++++++++++++++++15121513* Added file attribute to POST and PUT requests for multipart-encode file uploads.1514* Added Request.url attribute for context and redirects1515151615170.2.0 (2011-02-14)1518++++++++++++++++++15191520* Birth!1521152215230.0.1 (2011-02-13)1524++++++++++++++++++15251526* Frustration1527* Conception
modified:LICENSE+2 added-2 removed
1Copyright 2017 Kenneth Reitz1Copyright 2018 Kenneth Reitz23 Licensed under the Apache License, Version 2.0 (the "License");4 you may not use this file except in compliance with the License.5 You may obtain a copy of the License at67 http://www.apache.org/licenses/LICENSE-2.07 https://www.apache.org/licenses/LICENSE-2.089 Unless required by applicable law or agreed to in writing, software10 distributed under the License is distributed on an "AS IS" BASIS,11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2 unmodified lines
modified:Makefile+6 added-5 removed
1.PHONY: docs2init:3 pip install -r requirements.txt3 pip install pipenv --upgrade4 pipenv install --dev --skip-lock5test:6 # This runs all of the tests, on both Python 2 and Python 3.7 detox8ci:8 py.test -n 8 --boxed --junitxml=report.xml9 pipenv run py.test -n 8 --boxed --junitxml=report.xml1011test-readme:11 @python setup.py check --restructuredtext --strict && ([ $$? -eq 0 ] && echo "README.rst and HISTORY.rst ok") || echo "Invalid markup in README.rst or HISTORY.rst!"12 @pipenv run python setup.py check --restructuredtext --strict && ([ $$? -eq 0 ] && echo "README.rst and HISTORY.rst ok") || echo "Invalid markup in README.rst or HISTORY.rst!"1314flake8:14 flake8 --ignore=E501,F401,E128,E402,E731,F821 requests15 pipenv run flake8 --ignore=E501,F401,E128,E402,E731,F821 requests1617coverage:17 py.test --cov-config .coveragerc --verbose --cov-report term --cov-report xml --cov=requests tests18 pipenv run py.test --cov-config .coveragerc --verbose --cov-report term --cov-report xml --cov=requests tests1920publish:21 pip install 'twine>=1.5.0'22 python setup.py sdist bdist_wheel
6 unmodified lines
modified:MANIFEST.in+1 added-1 removed
1include README.rst LICENSE NOTICE HISTORY.rst pytest.ini requirements.txt1include README.md LICENSE NOTICE HISTORY.md pytest.ini requirements.txt Pipfile Pipfile.lock2recursive-include tests *.py
added:Pipfile+24 added
1[[source]]2url = "https://pypi.org/simple/"3verify_ssl = true4name = "pypi"56[dev-packages]7pytest = ">=2.8.0"8codecov = "*"9pytest-httpbin = ">=0.0.7"10pytest-mock = "*"11pytest-cov = "*"12pytest-xdist = "*"13alabaster = "*"14readme-renderer = "*"15sphinx = "<=1.5.5"16pysocks = "*"17docutils = "*"18"flake8" = "*"19tox = "*"20detox = "*"21httpbin = ">=0.7.0"2223[packages]24"e1839a8" = {path = ".", editable = true, extras = ["socks"]}
added:Pipfile.lock+641 added
1{2 "_meta": {3 "hash": {4 "sha256": "0735b243455d8e924fbd05188ed435bfd3917f4acdade9b9e8f14741f3fc47e9"5 },6 "pipfile-spec": 6,7 "requires": {},8 "sources": [9 {10 "name": "pypi",11 "url": "https://pypi.org/simple/",12 "verify_ssl": true13 }14 ]15 },16 "default": {17 "certifi": {18 "hashes": [19 "sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7",20 "sha256:9fa520c1bacfb634fa7af20a76bcbd3d5fb390481724c597da32c719a7dca4b0"21 ],22 "version": "==2018.4.16"23 },24 "chardet": {25 "hashes": [26 "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",27 "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"28 ],29 "version": "==3.0.4"30 },31 "e1839a8": {32 "editable": true,33 "extras": [34 "socks"35 ],36 "path": "."37 },38 "idna": {39 "hashes": [40 "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f",41 "sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4"42 ],43 "version": "==2.6"44 },45 "pysocks": {46 "hashes": [47 "sha256:3fe52c55890a248676fd69dc9e3c4e811718b777834bcaab7a8125cf9deac672"48 ],49 "version": "==1.6.8"50 },51 "urllib3": {52 "hashes": [53 "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b",54 "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f"55 ],56 "version": "==1.22"57 }58 },59 "develop": {60 "alabaster": {61 "hashes": [62 "sha256:2eef172f44e8d301d25aff8068fddd65f767a3f04b5f15b0f4922f113aa1c732",63 "sha256:37cdcb9e9954ed60912ebc1ca12a9d12178c26637abdf124e3cde2341c257fe0"64 ],65 "index": "pypi",66 "version": "==0.7.10"67 },68 "apipkg": {69 "hashes": [70 "sha256:2e38399dbe842891fe85392601aab8f40a8f4cc5a9053c326de35a1cc0297ac6",71 "sha256:65d2aa68b28e7d31233bb2ba8eb31cda40e4671f8ac2d6b241e358c9652a74b9"72 ],73 "version": "==1.4"74 },75 "attrs": {76 "hashes": [77 "sha256:4b90b09eeeb9b88c35bc642cbac057e45a5fd85367b985bd2809c62b7b939265",78 "sha256:e0d0eb91441a3b53dab4d9b743eafc1ac44476296a2053b6ca3af0b139faf87b"79 ],80 "version": "==18.1.0"81 },82 "babel": {83 "hashes": [84 "sha256:8ce4cb6fdd4393edd323227cba3a077bceb2a6ce5201c902c65e730046f41f14",85 "sha256:ad209a68d7162c4cff4b29cdebe3dec4cef75492df501b0049a9433c96ce6f80"86 ],87 "version": "==2.5.3"88 },89 "bleach": {90 "hashes": [91 "sha256:b8fa79e91f96c2c2cd9fd1f9eda906efb1b88b483048978ba62fef680e962b34",92 "sha256:eb7386f632349d10d9ce9d4a838b134d4731571851149f9cc2c05a9a837a9a44"93 ],94 "version": "==2.1.3"95 },96 "blinker": {97 "hashes": [98 "sha256:471aee25f3992bd325afa3772f1063dbdbbca947a041b8b89466dc00d606f8b6"99 ],100 "version": "==1.4"101 },102 "brotlipy": {103 "hashes": [104 "sha256:07194f4768eb62a4f4ea76b6d0df6ade185e24ebd85877c351daa0a069f1111a",105 "sha256:091b299bf36dd6ef7a06570dbc98c0f80a504a56c5b797f31934d2ad01ae7d17",106 "sha256:09ec3e125d16749b31c74f021aba809541b3564e5359f8c265cbae442810b41a",107 "sha256:0be698678a114addcf87a4b9496c552c68a2c99bf93cf8e08f5738b392e82057",108 "sha256:0fa6088a9a87645d43d7e21e32b4a6bf8f7c3939015a50158c10972aa7f425b7",109 "sha256:1ea4e578241504b58f2456a6c69952c88866c794648bdc74baee74839da61d44",110 "sha256:2699945a0a992c04fc7dc7fa2f1d0575a2c8b4b769f2874a08e8eae46bef36ae",111 "sha256:2a80319ae13ea8dd60ecdc4f5ccf6da3ae64787765923256b62c598c5bba4121",112 "sha256:2e5c64522364a9ebcdf47c5744a5ddeb3f934742d31e61ebfbbc095460b47162",113 "sha256:36def0b859beaf21910157b4c33eb3b06d8ce459c942102f16988cca6ea164df",114 "sha256:3a3e56ced8b15fbbd363380344f70f3b438e0fd1fcf27b7526b6172ea950e867",115 "sha256:3c1d5e2cf945a46975bdb11a19257fa057b67591eb232f393d260e7246d9e571",116 "sha256:50ca336374131cfad20612f26cc43c637ac0bfd2be3361495e99270883b52962",117 "sha256:5de6f7d010b7558f72f4b061a07395c5c3fd57f0285c5af7f126a677b976a868",118 "sha256:637847560d671657f993313ecc6c6c6666a936b7a925779fd044065c7bc035b9",119 "sha256:653faef61241bf8bf99d73ca7ec4baa63401ba7b2a2aa88958394869379d67c7",120 "sha256:786afc8c9bd67de8d31f46e408a3386331e126829114e4db034f91eacb05396d",121 "sha256:79aaf217072840f3e9a3b641cccc51f7fc23037496bd71e26211856b93f4b4cb",122 "sha256:7e31f7adcc5851ca06134705fcf3478210da45d35ad75ec181e1ce9ce345bb38",123 "sha256:8b39abc3256c978f575df5cd7893153277216474f303e26f0e43ba3d3969ef96",124 "sha256:9448227b0df082e574c45c983fa5cd4bda7bfb11ea6b59def0940c1647be0c3c",125 "sha256:96bc59ff9b5b5552843dc67999486a220e07a0522dddd3935da05dc194fa485c",126 "sha256:a07647886e24e2fb2d68ca8bf3ada398eb56fd8eac46c733d4d95c64d17f743b",127 "sha256:af65d2699cb9f13b26ec3ba09e75e80d31ff422c03675fcb36ee4dabe588fdc2",128 "sha256:b4c98b0d2c9c7020a524ca5bbff42027db1004c6571f8bc7b747f2b843128e7a",129 "sha256:c6cc0036b1304dd0073eec416cb2f6b9e37ac8296afd9e481cac3b1f07f9db25",130 "sha256:d2c1c724c4ac375feb2110f1af98ecdc0e5a8ea79d068efb5891f621a5b235cb",131 "sha256:dc6c5ee0df9732a44d08edab32f8a616b769cc5a4155a12d2d010d248eb3fb07",132 "sha256:fd1d1c64214af5d90014d82cee5d8141b13d44c92ada7a0c0ec0679c6f15a471"133 ],134 "version": "==0.7.0"135 },136 "certifi": {137 "hashes": [138 "sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7",139 "sha256:9fa520c1bacfb634fa7af20a76bcbd3d5fb390481724c597da32c719a7dca4b0"140 ],141 "version": "==2018.4.16"142 },143 "cffi": {144 "hashes": [145 "sha256:151b7eefd035c56b2b2e1eb9963c90c6302dc15fbd8c1c0a83a163ff2c7d7743",146 "sha256:1553d1e99f035ace1c0544050622b7bc963374a00c467edafac50ad7bd276aef",147 "sha256:1b0493c091a1898f1136e3f4f991a784437fac3673780ff9de3bcf46c80b6b50",148 "sha256:2ba8a45822b7aee805ab49abfe7eec16b90587f7f26df20c71dd89e45a97076f",149 "sha256:3c85641778460581c42924384f5e68076d724ceac0f267d66c757f7535069c93",150 "sha256:3eb6434197633b7748cea30bf0ba9f66727cdce45117a712b29a443943733257",151 "sha256:4c91af6e967c2015729d3e69c2e51d92f9898c330d6a851bf8f121236f3defd3",152 "sha256:770f3782b31f50b68627e22f91cb182c48c47c02eb405fd689472aa7b7aa16dc",153 "sha256:79f9b6f7c46ae1f8ded75f68cf8ad50e5729ed4d590c74840471fc2823457d04",154 "sha256:7a33145e04d44ce95bcd71e522b478d282ad0eafaf34fe1ec5bbd73e662f22b6",155 "sha256:857959354ae3a6fa3da6651b966d13b0a8bed6bbc87a0de7b38a549db1d2a359",156 "sha256:87f37fe5130574ff76c17cab61e7d2538a16f843bb7bca8ebbc4b12de3078596",157 "sha256:95d5251e4b5ca00061f9d9f3d6fe537247e145a8524ae9fd30a2f8fbce993b5b",158 "sha256:9d1d3e63a4afdc29bd76ce6aa9d58c771cd1599fbba8cf5057e7860b203710dd",159 "sha256:a36c5c154f9d42ec176e6e620cb0dd275744aa1d804786a71ac37dc3661a5e95",160 "sha256:ae5e35a2c189d397b91034642cb0eab0e346f776ec2eb44a49a459e6615d6e2e",161 "sha256:b0f7d4a3df8f06cf49f9f121bead236e328074de6449866515cea4907bbc63d6",162 "sha256:b75110fb114fa366b29a027d0c9be3709579602ae111ff61674d28c93606acca",163 "sha256:ba5e697569f84b13640c9e193170e89c13c6244c24400fc57e88724ef610cd31",164 "sha256:be2a9b390f77fd7676d80bc3cdc4f8edb940d8c198ed2d8c0be1319018c778e1",165 "sha256:d5d8555d9bfc3f02385c1c37e9f998e2011f0db4f90e250e5bc0c0a85a813085",166 "sha256:e55e22ac0a30023426564b1059b035973ec82186ddddbac867078435801c7801",167 "sha256:e90f17980e6ab0f3c2f3730e56d1fe9bcba1891eeea58966e89d352492cc74f4",168 "sha256:ecbb7b01409e9b782df5ded849c178a0aa7c906cf8c5a67368047daab282b184",169 "sha256:ed01918d545a38998bfa5902c7c00e0fee90e957ce036a4000a88e3fe2264917",170 "sha256:edabd457cd23a02965166026fd9bfd196f4324fe6032e866d0f3bd0301cd486f",171 "sha256:fdf1c1dc5bafc32bc5d08b054f94d659422b05aba244d6be4ddc1c72d9aa70fb"172 ],173 "version": "==1.11.5"174 },175 "chardet": {176 "hashes": [177 "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",178 "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"179 ],180 "version": "==3.0.4"181 },182 "click": {183 "hashes": [184 "sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",185 "sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"186 ],187 "version": "==6.7"188 },189 "cmarkgfm": {190 "hashes": [191 "sha256:0186dccca79483e3405217993b83b914ba4559fe9a8396efc4eea56561b74061",192 "sha256:1a625afc6f62da428df96ec325dc30866cc5781520cbd904ff4ec44cf018171c",193 "sha256:275905bb371a99285c74931700db3f0c078e7603bed383e8cf1a09f3ee05a3de",194 "sha256:50098f1c4950722521f0671e54139e0edc1837d63c990cf0f3d2c49607bb51a2",195 "sha256:50ed116d0b60a07df0dc7b180c28569064b9d37d1578d4c9021cff04d725cb63",196 "sha256:61a72def110eed903cd1848245897bcb80d295cd9d13944d4f9f30cba5b76655",197 "sha256:64186fb75d973a06df0e6ea12879533b71f6e7ba1ab01ffee7fc3e7534758889",198 "sha256:665303d34d7f14f10d7b0651082f25ebf7107f29ef3d699490cac16cdc0fc8ce",199 "sha256:70b18f843aec58e4e64aadce48a897fe7c50426718b7753aaee399e72df64190",200 "sha256:761ee7b04d1caee2931344ac6bfebf37102ffb203b136b676b0a71a3f0ea3c87",201 "sha256:811527e9b7280b136734ed6cb6845e5fbccaeaa132ddf45f0246cbe544016957",202 "sha256:987b0e157f70c72a84f3c2f9ef2d7ab0f26c08f2bf326c12c087ff9eebcb3ff5",203 "sha256:9fc6a2183d0a9b0974ec7cdcdad42bd78a3be674cc3e65f87dd694419b3b0ab7",204 "sha256:c573ea89dd95d41b6d8cf36799c34b6d5b1eac4aed0212dee0f0a11fb7b01e8f",205 "sha256:c5f1b9e8592d2c448c44e6bc0d91224b16ea5f8293908b1561de1f6d2d0658b1",206 "sha256:cbe581456357d8f0674d6a590b1aaf46c11d01dd0a23af147a51a798c3818034",207 "sha256:cf219bec69e601fe27e3974b7307d2f06082ab385d42752738ad2eb630a47d65",208 "sha256:d08bad67fa18f7e8ff738c090628ee0cbf0505d74a991c848d6d04abfe67b697",209 "sha256:d6f716d7b1182bf35862b5065112f933f43dd1aa4f8097c9bcfb246f71528a34",210 "sha256:e08e479102627641c7cb4ece421c6ed4124820b1758765db32201136762282d9",211 "sha256:e20ac21418af0298437d29599f7851915497ce9f2866bc8e86b084d8911ee061",212 "sha256:e25f53c37e319241b9a412382140dffac98ca756ba8f360ac7ab5e30cad9670a",213 "sha256:f20900f16377f2109783ae9348d34bc80530808439591c3d3df73d5c7ef1a00c"214 ],215 "version": "==0.4.2"216 },217 "codecov": {218 "hashes": [219 "sha256:8ed8b7c6791010d359baed66f84f061bba5bd41174bf324c31311e8737602788",220 "sha256:ae00d68e18d8a20e9c3288ba3875ae03db3a8e892115bf9b83ef20507732bed4"221 ],222 "index": "pypi",223 "version": "==2.0.15"224 },225 "configparser": {226 "hashes": [227 "sha256:5308b47021bc2340965c371f0f058cc6971a04502638d4244225c49d80db273a"228 ],229 "markers": "python_version < '3.2'",230 "version": "==3.5.0"231 },232 "contextlib2": {233 "hashes": [234 "sha256:509f9419ee91cdd00ba34443217d5ca51f5a364a404e1dce9e8979cea969ca48",235 "sha256:f5260a6e679d2ff42ec91ec5252f4eeffdcf21053db9113bd0a8e4d953769c00"236 ],237 "markers": "python_version < '3.2'",238 "version": "==0.5.5"239 },240 "coverage": {241 "hashes": [242 "sha256:03481e81d558d30d230bc12999e3edffe392d244349a90f4ef9b88425fac74ba",243 "sha256:0b136648de27201056c1869a6c0d4e23f464750fd9a9ba9750b8336a244429ed",244 "sha256:104ab3934abaf5be871a583541e8829d6c19ce7bde2923b2751e0d3ca44db60a",245 "sha256:15b111b6a0f46ee1a485414a52a7ad1d703bdf984e9ed3c288a4414d3871dcbd",246 "sha256:198626739a79b09fa0a2f06e083ffd12eb55449b5f8bfdbeed1df4910b2ca640",247 "sha256:1c383d2ef13ade2acc636556fd544dba6e14fa30755f26812f54300e401f98f2",248 "sha256:28b2191e7283f4f3568962e373b47ef7f0392993bb6660d079c62bd50fe9d162",249 "sha256:2eb564bbf7816a9d68dd3369a510be3327f1c618d2357fa6b1216994c2e3d508",250 "sha256:337ded681dd2ef9ca04ef5d93cfc87e52e09db2594c296b4a0a3662cb1b41249",251 "sha256:3a2184c6d797a125dca8367878d3b9a178b6fdd05fdc2d35d758c3006a1cd694",252 "sha256:3c79a6f7b95751cdebcd9037e4d06f8d5a9b60e4ed0cd231342aa8ad7124882a",253 "sha256:3d72c20bd105022d29b14a7d628462ebdc61de2f303322c0212a054352f3b287",254 "sha256:3eb42bf89a6be7deb64116dd1cc4b08171734d721e7a7e57ad64cc4ef29ed2f1",255 "sha256:4635a184d0bbe537aa185a34193898eee409332a8ccb27eea36f262566585000",256 "sha256:56e448f051a201c5ebbaa86a5efd0ca90d327204d8b059ab25ad0f35fbfd79f1",257 "sha256:5a13ea7911ff5e1796b6d5e4fbbf6952381a611209b736d48e675c2756f3f74e",258 "sha256:69bf008a06b76619d3c3f3b1983f5145c75a305a0fea513aca094cae5c40a8f5",259 "sha256:6bc583dc18d5979dc0f6cec26a8603129de0304d5ae1f17e57a12834e7235062",260 "sha256:701cd6093d63e6b8ad7009d8a92425428bc4d6e7ab8d75efbb665c806c1d79ba",261 "sha256:7608a3dd5d73cb06c531b8925e0ef8d3de31fed2544a7de6c63960a1e73ea4bc",262 "sha256:76ecd006d1d8f739430ec50cc872889af1f9c1b6b8f48e29941814b09b0fd3cc",263 "sha256:7aa36d2b844a3e4a4b356708d79fd2c260281a7390d678a10b91ca595ddc9e99",264 "sha256:7d3f553904b0c5c016d1dad058a7554c7ac4c91a789fca496e7d8347ad040653",265 "sha256:7e1fe19bd6dce69d9fd159d8e4a80a8f52101380d5d3a4d374b6d3eae0e5de9c",266 "sha256:8c3cb8c35ec4d9506979b4cf90ee9918bc2e49f84189d9bf5c36c0c1119c6558",267 "sha256:9d6dd10d49e01571bf6e147d3b505141ffc093a06756c60b053a859cb2128b1f",268 "sha256:9e112fcbe0148a6fa4f0a02e8d58e94470fc6cb82a5481618fea901699bf34c4",269 "sha256:ac4fef68da01116a5c117eba4dd46f2e06847a497de5ed1d64bb99a5fda1ef91",270 "sha256:b8815995e050764c8610dbc82641807d196927c3dbed207f0a079833ffcf588d",271 "sha256:be6cfcd8053d13f5f5eeb284aa8a814220c3da1b0078fa859011c7fffd86dab9",272 "sha256:c1bb572fab8208c400adaf06a8133ac0712179a334c09224fb11393e920abcdd",273 "sha256:de4418dadaa1c01d497e539210cb6baa015965526ff5afc078c57ca69160108d",274 "sha256:e05cb4d9aad6233d67e0541caa7e511fa4047ed7750ec2510d466e806e0255d6",275 "sha256:e4d96c07229f58cb686120f168276e434660e4358cc9cf3b0464210b04913e77",276 "sha256:f3f501f345f24383c0000395b26b726e46758b71393267aeae0bd36f8b3ade80",277 "sha256:f8a923a85cb099422ad5a2e345fe877bbc89a8a8b23235824a93488150e45f6e"278 ],279 "version": "==4.5.1"280 },281 "decorator": {282 "hashes": [283 "sha256:2c51dff8ef3c447388fe5e4453d24a2bf128d3a4c32af3fabef1f01c6851ab82",284 "sha256:c39efa13fbdeb4506c476c9b3babf6a718da943dab7811c206005a4a956c080c"285 ],286 "version": "==4.3.0"287 },288 "detox": {289 "hashes": [290 "sha256:cb24895a0e4f95c0bcb1087a201c453600e075568af00848e91518fb2b984568",291 "sha256:f3119bca4444f1e8a1d7189b064c52cfdd9a89ad3a1c921d78b49bf7f5dc5b1b"292 ],293 "index": "pypi",294 "version": "==0.12"295 },296 "docutils": {297 "hashes": [298 "sha256:02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6",299 "sha256:51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274",300 "sha256:7a4bd47eaf6596e1295ecb11361139febe29b084a87bf005bf899f9a42edc3c6"301 ],302 "index": "pypi",303 "version": "==0.14"304 },305 "enum34": {306 "hashes": [307 "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850",308 "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a",309 "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79",310 "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1"311 ],312 "markers": "python_version < '3.4'",313 "version": "==1.1.6"314 },315 "eventlet": {316 "hashes": [317 "sha256:06cffa55b335cc4fc32d0079242a81e8a9cddf2581d64d5f0543e2d412b26ca8",318 "sha256:554a50dad7abee0a9775b0780ce9d9c0bd9123dda4743c46d4314170267c6c47"319 ],320 "version": "==0.23.0"321 },322 "execnet": {323 "hashes": [324 "sha256:a7a84d5fa07a089186a329528f127c9d73b9de57f1a1131b82bb5320ee651f6a",325 "sha256:fc155a6b553c66c838d1a22dba1dc9f5f505c43285a878c6f74a79c024750b83"326 ],327 "version": "==1.5.0"328 },329 "flake8": {330 "hashes": [331 "sha256:7253265f7abd8b313e3892944044a365e3f4ac3fcdcfb4298f55ee9ddf188ba0",332 "sha256:c7841163e2b576d435799169b78703ad6ac1bbb0f199994fc05f700b2a90ea37"333 ],334 "index": "pypi",335 "version": "==3.5.0"336 },337 "flask": {338 "hashes": [339 "sha256:2271c0070dbcb5275fad4a82e29f23ab92682dc45f9dfbc22c02ba9b9322ce48",340 "sha256:a080b744b7e345ccfcbc77954861cb05b3c63786e93f2b3875e0913d44b43f05"341 ],342 "version": "==1.0.2"343 },344 "funcsigs": {345 "hashes": [346 "sha256:330cc27ccbf7f1e992e69fef78261dc7c6569012cf397db8d3de0234e6c937ca",347 "sha256:a7bb0f2cf3a3fd1ab2732cb49eba4252c2af4240442415b4abce3b87022a8f50"348 ],349 "markers": "python_version < '3.3'",350 "version": "==1.0.2"351 },352 "future": {353 "hashes": [354 "sha256:e39ced1ab767b5936646cedba8bcce582398233d6a627067d4c6a454c90cfedb"355 ],356 "version": "==0.16.0"357 },358 "greenlet": {359 "hashes": [360 "sha256:09ef2636ea35782364c830f07127d6c7a70542b178268714a9a9ba16318e7e8b",361 "sha256:0fef83d43bf87a5196c91e73cb9772f945a4caaff91242766c5916d1dd1381e4",362 "sha256:1b7df09c6598f5cfb40f843ade14ed1eb40596e75cd79b6fa2efc750ba01bb01",363 "sha256:1fff21a2da5f9e03ddc5bd99131a6b8edf3d7f9d6bc29ba21784323d17806ed7",364 "sha256:42118bf608e0288e35304b449a2d87e2ba77d1e373e8aa221ccdea073de026fa",365 "sha256:50643fd6d54fd919f9a0a577c5f7b71f5d21f0959ab48767bd4bb73ae0839500",366 "sha256:58798b5d30054bb4f6cf0f712f08e6092df23a718b69000786634a265e8911a9",367 "sha256:5b49b3049697aeae17ef7bf21267e69972d9e04917658b4e788986ea5cc518e8",368 "sha256:75c413551a436b462d5929255b6dc9c0c3c2b25cbeaee5271a56c7fda8ca49c0",369 "sha256:769b740aeebd584cd59232be84fdcaf6270b8adc356596cdea5b2152c82caaac",370 "sha256:ad2383d39f13534f3ca5c48fe1fc0975676846dc39c2cece78c0f1f9891418e0",371 "sha256:b417bb7ff680d43e7bd7a13e2e08956fa6acb11fd432f74c97b7664f8bdb6ec1",372 "sha256:b6ef0cabaf5a6ecb5ac122e689d25ba12433a90c7b067b12e5f28bdb7fb78254",373 "sha256:c2de19c88bdb0366c976cc125dca1002ec1b346989d59524178adfd395e62421",374 "sha256:c7b04a6dc74087b1598de8d713198de4718fa30ec6cbb84959b26426c198e041",375 "sha256:f8f2a0ae8de0b49c7b5b2daca4f150fdd9c1173e854df2cce3b04123244f9f45",376 "sha256:fcfadaf4bf68a27e5dc2f42cbb2f4b4ceea9f05d1d0b8f7787e640bed2801634"377 ],378 "version": "==0.4.13"379 },380 "html5lib": {381 "hashes": [382 "sha256:20b159aa3badc9d5ee8f5c647e5efd02ed2a66ab8d354930bd9ff139fc1dc0a3",383 "sha256:66cb0dcfdbbc4f9c3ba1a63fdb511ffdbd4f513b2b6d81b80cd26ce6b3fb3736"384 ],385 "version": "==1.0.1"386 },387 "httpbin": {388 "hashes": [389 "sha256:7a04b5904c80b7aa04dd0a6af6520d68ce17a5db175e66a64b971f8e93d73a26",390 "sha256:cbb37790c91575f4f15757f42ad41d9f729eb227d5edbe89e4ec175486db8dfa"391 ],392 "index": "pypi",393 "version": "==0.7.0"394 },395 "idna": {396 "hashes": [397 "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f",398 "sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4"399 ],400 "version": "==2.6"401 },402 "imagesize": {403 "hashes": [404 "sha256:3620cc0cadba3f7475f9940d22431fc4d407269f1be59ec9b8edcca26440cf18",405 "sha256:5b326e4678b6925158ccc66a9fa3122b6106d7c876ee32d7de6ce59385b96315"406 ],407 "version": "==1.0.0"408 },409 "itsdangerous": {410 "hashes": [411 "sha256:cbb3fcf8d3e33df861709ecaf89d9e6629cff0a217bc2848f1b41cd30d360519"412 ],413 "version": "==0.24"414 },415 "jinja2": {416 "hashes": [417 "sha256:74c935a1b8bb9a3947c50a54766a969d4846290e1e788ea44c1392163723c3bd",418 "sha256:f84be1bb0040caca4cea721fcbbbbd61f9be9464ca236387158b0feea01914a4"419 ],420 "version": "==2.10"421 },422 "markupsafe": {423 "hashes": [424 "sha256:a6be69091dac236ea9c6bc7d012beab42010fa914c459791d627dad4910eb665"425 ],426 "version": "==1.0"427 },428 "mccabe": {429 "hashes": [430 "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",431 "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"432 ],433 "version": "==0.6.1"434 },435 "mock": {436 "hashes": [437 "sha256:5ce3c71c5545b472da17b72268978914d0252980348636840bd34a00b5cc96c1",438 "sha256:b158b6df76edd239b8208d481dc46b6afd45a846b7812ff0ce58971cf5bc8bba"439 ],440 "markers": "python_version < '3.0'",441 "version": "==2.0.0"442 },443 "more-itertools": {444 "hashes": [445 "sha256:0dd8f72eeab0d2c3bd489025bb2f6a1b8342f9b198f6fc37b52d15cfa4531fea",446 "sha256:11a625025954c20145b37ff6309cd54e39ca94f72f6bb9576d1195db6fa2442e",447 "sha256:c9ce7eccdcb901a2c75d326ea134e0886abfbea5f93e91cc95de9507c0816c44"448 ],449 "version": "==4.1.0"450 },451 "pbr": {452 "hashes": [453 "sha256:680bf5ba9b28dd56e08eb7c267991a37c7a5f90a92c2e07108829931a50ff80a",454 "sha256:6874feb22334a1e9a515193cba797664e940b763440c88115009ec323a7f2df5"455 ],456 "version": "==4.0.3"457 },458 "pluggy": {459 "hashes": [460 "sha256:7f8ae7f5bdf75671a718d2daf0a64b7885f74510bcd98b1a0bb420eb9a9d0cff",461 "sha256:d345c8fe681115900d6da8d048ba67c25df42973bda370783cd58826442dcd7c",462 "sha256:e160a7fcf25762bb60efc7e171d4497ff1d8d2d75a3d0df7a21b76821ecbf5c5"463 ],464 "version": "==0.6.0"465 },466 "py": {467 "hashes": [468 "sha256:29c9fab495d7528e80ba1e343b958684f4ace687327e6f789a94bf3d1915f881",469 "sha256:983f77f3331356039fdd792e9220b7b8ee1aa6bd2b25f567a963ff1de5a64f6a"470 ],471 "version": "==1.5.3"472 },473 "pycodestyle": {474 "hashes": [475 "sha256:682256a5b318149ca0d2a9185d365d8864a768a28db66a84a2ea946bcc426766",476 "sha256:6c4245ade1edfad79c3446fadfc96b0de2759662dc29d07d80a6f27ad1ca6ba9"477 ],478 "version": "==2.3.1"479 },480 "pycparser": {481 "hashes": [482 "sha256:99a8ca03e29851d96616ad0404b4aad7d9ee16f25c9f9708a11faf2810f7b226"483 ],484 "version": "==2.18"485 },486 "pyflakes": {487 "hashes": [488 "sha256:08bd6a50edf8cffa9fa09a463063c425ecaaf10d1eb0335a7e8b1401aef89e6f",489 "sha256:8d616a382f243dbf19b54743f280b80198be0bca3a5396f1d2e1fca6223e8805"490 ],491 "version": "==1.6.0"492 },493 "pygments": {494 "hashes": [495 "sha256:78f3f434bcc5d6ee09020f92ba487f95ba50f1e3ef83ae96b9d5ffa1bab25c5d",496 "sha256:dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc"497 ],498 "version": "==2.2.0"499 },500 "pysocks": {501 "hashes": [502 "sha256:3fe52c55890a248676fd69dc9e3c4e811718b777834bcaab7a8125cf9deac672"503 ],504 "version": "==1.6.8"505 },506 "pytest": {507 "hashes": [508 "sha256:54713b26c97538db6ff0703a12b19aeaeb60b5e599de542e7fca0ec83b9038e8",509 "sha256:829230122facf05a5f81a6d4dfe6454a04978ea3746853b2b84567ecf8e5c526"510 ],511 "index": "pypi",512 "version": "==3.5.1"513 },514 "pytest-cov": {515 "hashes": [516 "sha256:03aa752cf11db41d281ea1d807d954c4eda35cfa1b21d6971966cc041bbf6e2d",517 "sha256:890fe5565400902b0c78b5357004aab1c814115894f4f21370e2433256a3eeec"518 ],519 "index": "pypi",520 "version": "==2.5.1"521 },522 "pytest-forked": {523 "hashes": [524 "sha256:e4500cd0509ec4a26535f7d4112a8cc0f17d3a41c29ffd4eab479d2a55b30805",525 "sha256:f275cb48a73fc61a6710726348e1da6d68a978f0ec0c54ece5a5fae5977e5a08"526 ],527 "version": "==0.2"528 },529 "pytest-httpbin": {530 "hashes": [531 "sha256:8cd57e27418a7d7d205fcc9802eea246ed06170e3065abfa76c6d9b40553592c",532 "sha256:d3919c5df0b644454129c0066a8ae62db40ac54bacb4cfd89d8cfa58615a4b42"533 ],534 "index": "pypi",535 "version": "==0.3.0"536 },537 "pytest-mock": {538 "hashes": [539 "sha256:53801e621223d34724926a5c98bd90e8e417ce35264365d39d6c896388dcc928",540 "sha256:d89a8209d722b8307b5e351496830d5cc5e192336003a485443ae9adeb7dd4c0"541 ],542 "index": "pypi",543 "version": "==1.10.0"544 },545 "pytest-xdist": {546 "hashes": [547 "sha256:be2662264b035920ba740ed6efb1c816a83c8a22253df7766d129f6a7bfdbd35",548 "sha256:e8f5744acc270b3e7d915bdb4d5f471670f049b6fbd163d4cbd52203b075d30f"549 ],550 "index": "pypi",551 "version": "==1.22.2"552 },553 "pytz": {554 "hashes": [555 "sha256:65ae0c8101309c45772196b21b74c46b2e5d11b6275c45d251b150d5da334555",556 "sha256:c06425302f2cf668f1bba7a0a03f3c1d34d4ebeef2c72003da308b3947c7f749"557 ],558 "version": "==2018.4"559 },560 "raven": {561 "hashes": [562 "sha256:1c641e5ebc2d4185560608e253970ca0d4b98475f4edf67735015a415f9e1d48",563 "sha256:95aecf76c414facaddbb056f3e98c7936318123e467728f2e50b3a66b65a6ef7"564 ],565 "version": "==6.8.0"566 },567 "readme-renderer": {568 "hashes": [569 "sha256:bde909eaa84d65b7942f7e6998c8b427b90b568b2630ff0306f4ca75f6d2a909",570 "sha256:e7e43a7ba49f08c3cb660d0f2e25b561f6b10b36c63f029060230aab2dc2875e"571 ],572 "index": "pypi",573 "version": "==20.0"574 },575 "requests": {576 "hashes": [577 "sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b",578 "sha256:9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e"579 ],580 "version": "==2.18.4"581 },582 "six": {583 "hashes": [584 "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9",585 "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb"586 ],587 "version": "==1.11.0"588 },589 "snowballstemmer": {590 "hashes": [591 "sha256:919f26a68b2c17a7634da993d91339e288964f93c274f1343e3bbbe2096e1128",592 "sha256:9f3bcd3c401c3e862ec0ebe6d2c069ebc012ce142cce209c098ccb5b09136e89"593 ],594 "version": "==1.2.1"595 },596 "sphinx": {597 "hashes": [598 "sha256:11f271e7a9398385ed730e90f0bb41dc3815294bdcd395b46ed2d033bc2e7d87",599 "sha256:4064ea6c56feeb268838cb8fbbee507d0c3d5d92fa63a7df935a916b52c9e2f5"600 ],601 "index": "pypi",602 "version": "==1.5.5"603 },604 "tox": {605 "hashes": [606 "sha256:96efa09710a3daeeb845561ebbe1497641d9cef2ee0aea30db6969058b2bda2f",607 "sha256:9ee7de958a43806402a38c0d2aa07fa8553f4d2c20a15b140e9f771c2afeade0"608 ],609 "index": "pypi",610 "version": "==3.0.0"611 },612 "urllib3": {613 "hashes": [614 "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b",615 "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f"616 ],617 "version": "==1.22"618 },619 "virtualenv": {620 "hashes": [621 "sha256:1d7e241b431e7afce47e77f8843a276f652699d1fa4f93b9d8ce0076fd7b0b54",622 "sha256:e8e05d4714a1c51a2f5921e62f547fcb0f713ebbe959e0a7f585cc8bef71d11f"623 ],624 "version": "==15.2.0"625 },626 "webencodings": {627 "hashes": [628 "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78",629 "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"630 ],631 "version": "==0.5.1"632 },633 "werkzeug": {634 "hashes": [635 "sha256:c3fd7a7d41976d9f44db327260e263132466836cef6f91512889ed60ad26557c",636 "sha256:d5da73735293558eb1651ee2fddc4d0dedcfa06538b8813a2e20011583c9e49b"637 ],638 "version": "==0.14.1"639 }640 }641}
added:README.md+107 added
1Requests: HTTP for Humans™2==========================34[![image](https://img.shields.io/pypi/v/requests.svg)](https://pypi.org/project/requests/)5[![image](https://img.shields.io/pypi/l/requests.svg)](https://pypi.org/project/requests/)6[![image](https://img.shields.io/pypi/pyversions/requests.svg)](https://pypi.org/project/requests/)7[![codecov.io](https://codecov.io/github/requests/requests/coverage.svg?branch=master)](https://codecov.io/github/requests/requests)8[![image](https://img.shields.io/github/contributors/requests/requests.svg)](https://github.com/requests/requests/graphs/contributors)9[![image](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/kennethreitz)1011**If you're interested in financially supporting Kenneth Reitz open source, consider [visiting this link](https://cash.me/$KennethReitz). Your support helps tremendously with sustainability of motivation, as Open Source is no longer part of my day job.**1213Requests is the only *Non-GMO* HTTP library for Python, safe for human14consumption.1516![image](https://farm5.staticflickr.com/4317/35198386374_1939af3de6_k_d.jpg)1718Behold, the power of Requests:1920``` {.sourceCode .python}21>>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))22>>> r.status_code2320024>>> r.headers['content-type']25'application/json; charset=utf8'26>>> r.encoding27'utf-8'28>>> r.text29u'{"type":"User"...'30>>> r.json()31{u'disk_usage': 368627, u'private_gists': 484, ...}32```3334See [the similar code, sans Requests](https://gist.github.com/973705).3536[![image](https://raw.githubusercontent.com/requests/requests/master/docs/_static/requests-logo-small.png)](http://docs.python-requests.org/)3738Requests allows you to send *organic, grass-fed* HTTP/1.1 requests,39without the need for manual labor. There's no need to manually add query40strings to your URLs, or to form-encode your POST data. Keep-alive and41HTTP connection pooling are 100% automatic, thanks to42[urllib3](https://github.com/shazow/urllib3).4344Besides, all the cool kids are doing it. Requests is one of the most45downloaded Python packages of all time, pulling in over 11,000,00046downloads every month. You don't want to be left out!4748Feature Support49---------------5051Requests is ready for today's web.5253- International Domains and URLs54- Keep-Alive & Connection Pooling55- Sessions with Cookie Persistence56- Browser-style SSL Verification57- Basic/Digest Authentication58- Elegant Key/Value Cookies59- Automatic Decompression60- Automatic Content Decoding61- Unicode Response Bodies62- Multipart File Uploads63- HTTP(S) Proxy Support64- Connection Timeouts65- Streaming Downloads66- `.netrc` Support67- Chunked Requests6869Requests officially supports Python 2.7 & 3.4–3.7, and runs great on70PyPy.7172Installation73------------7475To install Requests, simply use [pipenv](http://pipenv.org/) (or pip, of76course):7778``` {.sourceCode .bash}79$ pipenv install requests80✨🍰✨81```8283Satisfaction guaranteed.8485Documentation86-------------8788Fantastic documentation is available at89<http://docs.python-requests.org/>, for a limited time only.9091How to Contribute92-----------------93941. Check for open issues or open a fresh issue to start a discussion95 around a feature idea or a bug. There is a [Contributor96 Friendly](https://github.com/requests/requests/issues?direction=desc&labels=Contributor+Friendly&page=1&sort=updated&state=open)97 tag for issues that should be ideal for people who are not very98 familiar with the codebase yet.992. Fork [the repository](https://github.com/requests/requests) on100 GitHub to start making your changes to the **master** branch (or101 branch off of it).1023. Write a test which shows that the bug was fixed or that the feature103 works as expected.1044. Send a pull request and bug the maintainer until it gets merged and105 published. :) Make sure to add yourself to106 [AUTHORS](https://github.com/requests/requests/blob/master/AUTHORS.rst).107
deleted:README.rst-114 removed
1Requests: HTTP for Humans2=========================34.. image:: https://img.shields.io/pypi/v/requests.svg5 :target: https://pypi.python.org/pypi/requests67.. image:: https://img.shields.io/pypi/l/requests.svg8 :target: https://pypi.python.org/pypi/requests910.. image:: https://img.shields.io/pypi/pyversions/requests.svg11 :target: https://pypi.python.org/pypi/requests1213.. image:: https://codecov.io/github/requests/requests/coverage.svg?branch=master14 :target: https://codecov.io/github/requests/requests15 :alt: codecov.io1617.. image:: https://img.shields.io/github/contributors/requests/requests.svg18 :target: https://github.com/requests/requests/graphs/contributors1920.. image:: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg21 :target: https://saythanks.io/to/kennethreitz22232425Requests is the only *Non-GMO* HTTP library for Python, safe for human26consumption.2728**Warning:** Recreational use of the Python standard library for HTTP may result in dangerous side-effects,29including: security vulnerabilities, verbose code, reinventing the wheel,30constantly reading documentation, depression, headaches, or even death.3132Behold, the power of Requests:3334.. code-block:: python3536 >>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))37 >>> r.status_code38 20039 >>> r.headers['content-type']40 'application/json; charset=utf8'41 >>> r.encoding42 'utf-8'43 >>> r.text44 u'{"type":"User"...'45 >>> r.json()46 {u'disk_usage': 368627, u'private_gists': 484, ...}4748See `the similar code, sans Requests <https://gist.github.com/973705>`_.4950.. image:: https://raw.githubusercontent.com/requests/requests/master/docs/_static/requests-logo-small.png51 :target: http://docs.python-requests.org/525354Requests allows you to send *organic, grass-fed* HTTP/1.1 requests, without the55need for manual labor. There's no need to manually add query strings to your56URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling57are 100% automatic, thanks to `urllib3 <https://github.com/shazow/urllib3>`_.5859Besides, all the cool kids are doing it. Requests is one of the most60downloaded Python packages of all time, pulling in over 11,000,000 downloads61every month. You don't want to be left out!6263Feature Support64---------------6566Requests is ready for today's web.6768- International Domains and URLs69- Keep-Alive & Connection Pooling70- Sessions with Cookie Persistence71- Browser-style SSL Verification72- Basic/Digest Authentication73- Elegant Key/Value Cookies74- Automatic Decompression75- Automatic Content Decoding76- Unicode Response Bodies77- Multipart File Uploads78- HTTP(S) Proxy Support79- Connection Timeouts80- Streaming Downloads81- ``.netrc`` Support82- Chunked Requests8384Requests officially supports Python 2.6–2.7 & 3.3–3.7, and runs great on PyPy.8586Installation87------------8889To install Requests, simply:9091.. code-block:: bash9293 $ pip install requests94 ✨🍰✨9596Satisfaction guaranteed.9798Documentation99-------------100101Fantastic documentation is available at http://docs.python-requests.org/, for a limited time only.102103104How to Contribute105-----------------106107#. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. There is a `Contributor Friendly`_ tag for issues that should be ideal for people who are not very familiar with the codebase yet.108#. Fork `the repository`_ on GitHub to start making your changes to the **master** branch (or branch off of it).109#. Write a test which shows that the bug was fixed or that the feature works as expected.110#. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS_.111112.. _`the repository`: http://github.com/requests/requests113.. _AUTHORS: https://github.com/requests/requests/blob/master/AUTHORS.rst114.. _Contributor Friendly: https://github.com/requests/requests/issues?direction=desc&labels=Contributor+Friendly&page=1&sort=updated&state=open
deleted:requirements.txt-16 removed
1-e .[socks]2pytest>=2.8.03codecov4pytest-httpbin==0.0.75pytest-mock6pytest-cov7pytest-xdist8alabaster9readme_renderer10Sphinx<=1.5.511PySocks12setuptools>=18.513docutils14flake815tox16detox
modified:setup.cfg+3 added
1[bdist_wheel]2universal = 134[metadata]5license_file = LICENSE
modified:setup.py+22 added-14 removed
1#!/usr/bin/env python22# Learn more: https://github.com/kennethreitz/setup.py3import os4import re5import sys6
35 unmodified lines
42packages = ['requests']4344requires = [45 'chardet>=3.0.2,<3.1.0',46 'idna>=2.5,<2.7',47 'urllib3>=1.21.1,<1.23',46 'idna>=2.5,<2.8',47 'urllib3>=1.21.1,<1.25',48 'certifi>=2017.4.17'4950]51test_requirements = ['pytest-httpbin==0.0.7', 'pytest-cov', 'pytest-mock', 'pytest-xdist', 'PySocks>=1.5.6, !=1.5.7', 'pytest>=2.8.0']51test_requirements = [52 'pytest-httpbin==0.0.7',53 'pytest-cov',54 'pytest-mock',55 'pytest-xdist',56 'PySocks>=1.5.6, !=1.5.7',57 'pytest>=2.8.0'58]5960about = {}61with open(os.path.join(here, 'requests', '__version__.py'), 'r', 'utf-8') as f:62 exec(f.read(), about)6357with open('README.rst', 'r', 'utf-8') as f:64with open('README.md', 'r', 'utf-8') as f:65 readme = f.read()59with open('HISTORY.rst', 'r', 'utf-8') as f:66with open('HISTORY.md', 'r', 'utf-8') as f:67 history = f.read()6869setup(70 name=about['__title__'],71 version=about['__version__'],72 description=about['__description__'],66 long_description=readme + '\n\n' + history,73 long_description=readme,74 long_description_content_type='text/markdown',75 author=about['__author__'],76 author_email=about['__author_email__'],77 url=about['__url__'],78 packages=packages,79 package_data={'': ['LICENSE', 'NOTICE'], 'requests': ['*.pem']},80 package_dir={'requests': 'requests'},81 include_package_data=True,82 python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",83 install_requires=requires,84 license=about['__license__'],85 zip_safe=False,77 classifiers=(86 classifiers=[87 'Development Status :: 5 - Production/Stable',88 'Intended Audience :: Developers',89 'Natural Language :: English',90 'License :: OSI Approved :: Apache Software License',91 'Programming Language :: Python',83 'Programming Language :: Python :: 2.6',92 'Programming Language :: Python :: 2',93 'Programming Language :: Python :: 2.7',94 'Programming Language :: Python :: 3',86 'Programming Language :: Python :: 3.3',95 'Programming Language :: Python :: 3.4',96 'Programming Language :: Python :: 3.5',97 'Programming Language :: Python :: 3.6',98 'Programming Language :: Python :: 3.7',99 'Programming Language :: Python :: Implementation :: CPython',100 'Programming Language :: Python :: Implementation :: PyPy'92 ),101 ],102 cmdclass={'test': PyTest},103 tests_require=test_requirements,104 extras_require={96 'security': ['pyOpenSSL>=0.14', 'cryptography>=1.3.4', 'idna>=2.0.0'],105 'security': ['pyOpenSSL >= 0.14', 'cryptography>=1.3.4', 'idna>=2.0.0'],106 'socks': ['PySocks>=1.5.6, !=1.5.7'],98 'socks:sys_platform == "win32" and (python_version == "2.7" or python_version == "2.6")': ['win_inet_pton'],107 'socks:sys_platform == "win32" and python_version == "2.7"': ['win_inet_pton'],108 },109)101
modified:tox.ini+2 added-2 removed
1[tox]2envlist = py26,py27,py33,py34,py35,py362envlist = py27,py34,py35,py3634[testenv]56commands =7 pip install -e .[socks]8 python setup.py test8 python setup.py test