Merge remote-tracking branch 'upstream/master' into utils-unit-tests
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Conflicts: tests/test_utils.py
authored by Dmitry Dygalo · committed by Dmitry Dygalo · parents f123f89, 190cddd · Browse files · 27 files·+1055 added−514 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
27 files+1055 added−514 removed
- tests:+46 added−0 removed
- other:+1009 added−514 removed
Provenance
- Commit
1eb1535- Tree
2ca2fce- Author
Dmitry Dygalo <dadygalo@gmail.com>- Committer
Dmitry Dygalo <dadygalo@gmail.com>- Parent 1
f123f89- Parent 2
190cddd
27 files changed+1055 added−514 removed
added:docs/_static/konami.js+116 added
1+/*2+ * Konami-JS ~3+ * :: Now with support for touch events and multiple instances for4+ * :: those situations that call for multiple easter eggs!5+ * Code: http://konami-js.googlecode.com/6+ * Examples: http://www.snaptortoise.com/konami-js7+ * Copyright (c) 2009 George Mandis (georgemandis.com, snaptortoise.com)8+ * Version: 1.4.2 (9/2/2013)9+ * Licensed under the MIT License (http://opensource.org/licenses/MIT)10+ * Tested in: Safari 4+, Google Chrome 4+, Firefox 3+, IE7+, Mobile Safari 2.2.1 and Dolphin Browser11+ */12+13+var Konami = function (callback) {14+ var konami = {15+ addEvent: function (obj, type, fn, ref_obj) {16+ if (obj.addEventListener)17+ obj.addEventListener(type, fn, false);18+ else if (obj.attachEvent) {19+ // IE20+ obj["e" + type + fn] = fn;21+ obj[type + fn] = function () {22+ obj["e" + type + fn](window.event, ref_obj);23+ };24+ obj.attachEvent("on" + type, obj[type + fn]);25+ }26+ },27+ input: "",28+ pattern: "38384040373937396665",29+ load: function (link) {30+ this.addEvent(document, "keydown", function (e, ref_obj) {31+ if (ref_obj) konami = ref_obj; // IE32+ konami.input += e ? e.keyCode : event.keyCode;33+ if (konami.input.length > konami.pattern.length)34+ konami.input = konami.input.substr((konami.input.length - konami.pattern.length));35+ if (konami.input == konami.pattern) {36+ konami.code(link);37+ konami.input = "";38+ e.preventDefault();39+ return false;40+ }41+ }, this);42+ this.iphone.load(link);43+ },44+ code: function (link) {45+ window.location = link46+ },47+ iphone: {48+ start_x: 0,49+ start_y: 0,50+ stop_x: 0,51+ stop_y: 0,52+ tapTolerance: 8,53+ capture: false,54+ orig_keys: "",55+ keys: ["UP", "UP", "DOWN", "DOWN", "LEFT", "RIGHT", "LEFT", "RIGHT", "TAP", "TAP"],56+ code: function (link) {57+ konami.code(link);58+ },59+ touchCapture: function(evt) {60+ konami.iphone.start_x = evt.changedTouches[0].pageX;61+ konami.iphone.start_y = evt.changedTouches[0].pageY;62+ konami.iphone.capture = true; 63+ },64+ load: function (link) {65+ this.orig_keys = this.keys;66+ konami.addEvent(document, "touchmove", function (e) {67+ if (e.touches.length == 1 && konami.iphone.capture == true) {68+ var touch = e.touches[0];69+ konami.iphone.stop_x = touch.pageX;70+ konami.iphone.stop_y = touch.pageY;71+ konami.iphone.check_direction();72+ }73+ });74+ konami.addEvent(document, "touchend", function (evt) {75+ konami.touchCapture(evt);76+ konami.iphone.check_direction(link);77+ }, false);78+ konami.addEvent(document, "touchstart", function (evt) {79+ konami.touchCapture(evt);80+ });81+ },82+ check_direction: function (link) {83+ var x_magnitude = Math.abs(this.start_x - this.stop_x);84+ var y_magnitude = Math.abs(this.start_y - this.stop_y);85+ var hasMoved = (x_magnitude > this.tapTolerance || y_magnitude > this.tapTolerance);86+ var result;87+ if (this.capture === true && hasMoved) {88+ this.capture = false;89+ var x = ((this.start_x - this.stop_x) < 0) ? "RIGHT" : "LEFT";90+ var y = ((this.start_y - this.stop_y) < 0) ? "DOWN" : "UP";91+ var result = (x_magnitude > y_magnitude) ? x : y;92+ }93+ else if (this.capture === false && !hasMoved) {94+ result = (this.tap == true) ? "TAP" : result;95+ result = "TAP";96+ }97+ if (result) {98+ if (result == this.keys[0]) this.keys = this.keys.slice(1, this.keys.length);99+ else this.keys = this.orig_keys;100+ }101+ if (this.keys.length == 0) {102+ this.keys = this.orig_keys;103+ this.code(link);104+ }105+ }106+ }107+ }108+109+ typeof callback === "string" && konami.load(callback);110+ if (typeof callback === "function") {111+ konami.code = callback;112+ konami.load();113+ }114+115+ return konami;116+};added:docs/_templates/hacks.html+54 added
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354<!-- Alabaster (krTheme++) Hacks -->
<!-- CSS Adjustments (I'm very picky.) --><style type="text/css">
/* Rezzy requires precise alignment. */ img.logo {margin-left: -20px!important;}
/* "Quick Search" should be capitalized. */ div#searchbox h3 {text-transform: capitalize;}
/* Make the document a little wider, less code is cut-off. */ div.document {width: 1008px;}
/* Much-improved spacing around code blocks. */ div.highlight pre {padding: 11px 14px;}
/* Remain Responsive! */ @media screen and (max-width: 1008px) { div.sphinxsidebar {display: none;} div.document {width: 100%!important;}
/* Have code blocks escape the document right-margin. */ div.highlight pre {margin-right: -30px;} }
</style>
<!-- Analytics tracking for Kenneth. --><script type="text/javascript"> var _gauges = _gauges || []; (function() { var t = document.createElement('script'); t.type = 'text/javascript'; t.async = true; t.id = 'gauges-tracker'; t.setAttribute('data-site-id', '56ca7a57c88d9011080024dd'); t.setAttribute('data-track-path', 'https://track.gaug.es/track.gif'); t.src = 'https://d36ee2fcip1434.cloudfront.net/track.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(t, s); })();</script>
<!-- There are no more hacks. --><!-- இڿڰۣ-ڰۣ— --><!-- Love, Kenneth Reitz -->
<script src="{{ pathto('_static/', 1) }}/konami.js"></script><script> var easter_egg = new Konami('http://fortunes.herokuapp.com/random/raw');</script>
<!-- That was not a hack. That was art. -->No newline at end of filedeleted:docs/_templates/layout.html-86 removed
1-{%- extends "basic/layout.html" %}2-{%- block extrahead %}3-4- {{ super() }}5-6- {% if theme_touch_icon %}7- <link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />8- {% endif %}9-10- <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">11-12- <style type="text/css">13- img.logo {margin-left: -20px!important;}14- </style>15-16-{% endblock %}17-{%- block relbar2 %}{% endblock %}18-{%- block footer %}19- <div class="footer">20- © Copyright {{ copyright }}.21- </div>22- <a href="https://github.com/kennethreitz/requests" class="github">23- <img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" class="github"/>24- </a>25-26- <script type="text/javascript" src="https://gumroad.com/js/gumroad.js"></script>27-28- <script type="text/javascript">29- /* <![CDATA[ */30- (function() {31- var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];32- s.type = 'text/javascript';33- s.async = true;34- s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';35- t.parentNode.insertBefore(s, t);36- })();37- /* ]]> */38- </script>39- <script type="text/javascript">40- setTimeout(function(){var a=document.createElement("script");41- var b=document.getElementsByTagName("script")[0];42- a.src=document.location.protocol+"//dnn506yrbagrg.cloudfront.net/pages/scripts/0013/7219.js?"+Math.floor(new Date().getTime()/3600000);43- a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);44- </script>45-46-47- <script type="text/javascript">48-49- var _gaq = _gaq || [];50- _gaq.push(['_setAccount', 'UA-8742933-11']);51- _gaq.push(['_setDomainName', 'none']);52- _gaq.push(['_setAllowLinker', true]);53- _gaq.push(['_trackPageview']);54-55- (function() {56- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;57- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';58- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);59- })();60-61- </script>62-63- <script type="text/javascript">64- (function() {65- var t = document.createElement('script');66- t.type = 'text/javascript';67- t.async = true;68- t.id = 'gauges-tracker';69- t.setAttribute('data-site-id',70- '4ddc27f6613f5d186d000007');71- t.src = '//secure.gaug.es/track.js';72- var s = document.getElementsByTagName('script')[0];73- s.parentNode.insertBefore(t, s);74- })();75- </script>76-77- <script type="text/javascript">78- (function() {79- window._pa = window._pa || {};80- _pa.productId = "requests-docs";81- var pa = document.createElement('script'); pa.type = 'text/javascript'; pa.async = true;82- pa.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + "//tag.perfectaudience.com/serve/5226171f87bc6890da0000a0.js";83- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(pa, s);84- })();85-</script>86-{%- endblock %}modified:docs/_templates/sidebarintro.html+31 added-16 removed
12 unmodified lines1314151617181918192020212223242324252626272828292930313233343536373831323334353637383940414243443 unmodified lines4849505152535455565758596061626364656612 unmodified lines Requests is an elegant and simple HTTP library for Python, built for human beings.</p>
<h3>Stay Informed</h3><p>Receive updates on new releases and upcoming projects.</p>
<p> <a href="https://gumroad.com/l/RRZc" class="gumroad-button">Buy Requests Pro</a></p><p><iframe src="http://ghbtns.com/github-btn.html?user=kennethreitz&type=follow&count=false" allowtransparency="true" frameborder="0" scrolling="0" width="200" height="20"></iframe></p>
<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>
<h3>Get Updates</h3><p>Receive updates on new releases and upcoming projects.</p><p><a href="http://tinyletter.com/kennethreitz">Join Mailing List</a>.</p>
<p><a href="http://tinyletter.com/kennethreitz">Subscribe to Newsletter</a></p><h3>Other Projects</h3>
<h3>Translations</h3><p>More <a href="http://kennethreitz.org/">Kenneth Reitz</a> projects:</p><ul><li><a href="http://docs.python-requests.org/">English</a></li><li><a href="http://fr.python-requests.org/">French</a></li><li><a href="http://de.python-requests.org/">German</a></li><li><a href="http://jp.python-requests.org/">Japanese</a></li><li><a href="http://cn.python-requests.org/">Chinese</a></li><li><a href="http://pt.python-requests.org/">Portuguese</a></li><li><a href="http://it.python-requests.org/">Italian</a></li><li><a href="http://es.python-requests.org/">Spanish</a></li> <li><a href="http://pep8.org/">pep8.org</a></li> <li><a href="http://httpbin.org/">httpbin.org</a></li> <li><a href="http://python-guide.org">The Python Guide</a></li> <li><a href="https://github.com/kennethreitz/records">Records: SQL for Humans</a></li> <li><a href="http://www.git-legit.org">Legit: Git for Humans</a></li> <li><a href="http://docs.python-tablib.org/en/latest/">Tablib: Tabular Datasets</a></li> <li><a href="http://markdownplease.com">Markdown, Please!</a></li></ul>
<h3>Useful Links</h3><ul> <li><a href="http://docs.python-requests.org/en/latest/community/recommended/">Recommended Packages and Extensions</a></li>
3 unmodified lines <li><a href="http://pypi.python.org/pypi/requests">Requests @ PyPI</a></li> <li><a href="http://github.com/kennethreitz/requests/issues">Issue Tracker</a></li> <li><a href="http://docs.python-requests.org/en/latest/community/updates/#software-updates">Release History</a></li></ul>
<h3>Translations</h3>
<ul> <li><a href="http://docs.python-requests.org/">English</a></li> <li><a href="http://fr.python-requests.org/">French</a></li> <li><a href="http://de.python-requests.org/">German</a></li> <li><a href="http://jp.python-requests.org/">Japanese</a></li> <li><a href="http://cn.python-requests.org/">Chinese</a></li> <li><a href="http://pt.python-requests.org/">Portuguese</a></li> <li><a href="http://it.python-requests.org/">Italian</a></li> <li><a href="http://es.python-requests.org/">Spanish</a></li></ul>
modified:docs/_templates/sidebarlogo.html+33 added-6 removed
12 unmodified lines131415161718192021171819242021222324252627282930313233343536373839404142434445464748495051525312 unmodified lines human beings. You are currently looking at the documentation of the development release.</p>
<p> <a href="https://gumroad.com/l/RRZc" class="gumroad-button">Buy Requests Pro</a></p>
<h3>Get Updates</h3><h3>Stay Informed</h3><p>Receive updates on new releases and upcoming projects.</p>
<p><a href="http://tinyletter.com/kennethreitz">Subscribe to Newsletter</a></p><p><a href="http://tinyletter.com/kennethreitz">Join Mailing List</a>.</p>
<p><iframe src="http://ghbtns.com/github-btn.html?user=kennethreitz&type=follow&count=false" allowtransparency="true" frameborder="0" scrolling="0" width="200" height="20"></iframe></p>
<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>
<h3>Other Projects</h3>
<p>More <a href="http://kennethreitz.org/">Kenneth Reitz</a> projects:</p><ul> <li><a href="http://pep8.org/">pep8.org</a></li> <li><a href="http://httpbin.org/">httpbin.org</a></li> <li><a href="http://python-guide.org">The Python Guide</a></li> <li><a href="https://github.com/kennethreitz/records">Records: SQL for Humans</a></li> <li><a href="http://www.git-legit.org">Legit: Git for Humans</a></li> <li><a href="http://docs.python-tablib.org/en/latest/">Tablib: Tabular Datasets</a></li> <li><a href="http://markdownplease.com">Markdown, Please!</a></li></ul>
<h3>Translations</h3>
<ul> <li><a href="http://docs.python-requests.org/">English</a></li> <li><a href="http://fr.python-requests.org/">French</a></li> <li><a href="http://de.python-requests.org/">German</a></li> <li><a href="http://jp.python-requests.org/">Japanese</a></li> <li><a href="http://cn.python-requests.org/">Chinese</a></li> <li><a href="http://pt.python-requests.org/">Portuguese</a></li> <li><a href="http://it.python-requests.org/">Italian</a></li> <li><a href="http://es.python-requests.org/">Spanish</a></li></ul>
modified:docs/dev/contributing.rst+94 added-33 removed
1 unmodified line2 3 Contributor's Guide4 ===================5 6-If you're reading this you're probably interested in contributing to7-Requests. First, We'd like to say: thank you! Open source projects8-live-and-die based on the support they receive from others, and the fact that9-you're even considering supporting Requests is very generous of10-you.6+If you're reading this, you're probably interested in contributing to Requests.7+Thank you very much! Open source projects live-and-die based on the support8+they receive from others, and the fact that you're even considering9+contributing to the Requests project is *very* generous of you.10 12-This document lays out guidelines and advice for contributing to Requests.13-If you're thinking of contributing, start by reading this thoroughly and14-getting a feel for how contributing to the project works. If you have any11+This document lays out guidelines and advice for contributing to this project.12+If you're thinking of contributing, please start by reading this document and13+getting a feel for how contributing to this project works. If you have any14 questions, feel free to reach out to either `Ian Cordasco`_ or `Cory Benfield`_,15 the primary maintainers.16 18-The guide is split into sections based on the type of contribution you're19-thinking of making, with a section that covers general guidelines for all20-contributors.21-17 .. _Ian Cordasco: http://www.coglib.com/~icordasc/18 .. _Cory Benfield: https://lukasa.co.uk/about19 20+If you have non-technical feedback, philosophical ponderings, crazy ideas, or21+other general thoughts about Requests or its position within the Python22+ecosystem, the BDFL, `Kenneth Reitz`_, would love to hear from you.23 26-All Contributions27------------------24+The guide is split into sections based on the type of contribution you're25+thinking of making, with a section that covers general guidelines for all26+contributors.27 28+.. _Kenneth Reitz: mailto:me@kennethreitz.org29+30 Be Cordial30-~~~~~~~~~~31+----------32 32-**Be cordial or be on your way.**33+ **Be cordial or be on your way**. *—Kenneth Reitz*34 35 Requests has one very important rule governing all forms of contribution,36 including reporting bugs or requesting features. This golden rule is37+"`be cordial or be on your way`_".38+36-`be cordial or be on your way`_. **All contributions are welcome**, as long as39+**All contributions are welcome**, as long as40 everyone involved is treated with respect.41 42 .. _be cordial or be on your way: http://kennethreitz.org/be-cordial-or-be-on-your-way/43 44 .. _early-feedback:45 46 Get Early Feedback44-~~~~~~~~~~~~~~~~~~47+------------------48 49 If you are contributing, do not feel the need to sit on your contribution until50 it is perfectly polished and complete. It helps everyone involved for you to51 seek feedback as early as you possibly can. Submitting an early, unfinished1 unmodified line53 getting that contribution accepted, and can save you from putting a lot of work54 into a contribution that is not suitable for the project.55 56 Contribution Suitability54-~~~~~~~~~~~~~~~~~~~~~~~~57+------------------------58 56-The project maintainer has the last word on whether or not a contribution is57-suitable for Requests. All contributions will be considered, but from time58-to time contributions will be rejected because they do not suit the project.59+Our project maintainers have the last word on whether or not a contribution is60+suitable for Requests. All contributions will be considered carefully, but from61+time to time, contributions will be rejected because they do not suit the62+current goals or needs of the project.63 60-If your contribution is rejected, don't despair! So long as you followed these61-guidelines, you'll have a much better chance of getting your next contribution62-accepted.64+If your contribution is rejected, don't despair! As long as you followed these65+guidelines, you will have a much better chance of getting your next66+contribution accepted.67 68 69 Code Contributions70 ------------------71 68-Steps69-~~~~~72+Steps for Submitting Code73+~~~~~~~~~~~~~~~~~~~~~~~~~74 75 When contributing code, you'll want to follow this checklist:76 77 1. Fork the repository on GitHub.29 unmodified lines107 asking for help.108 109 Please also check the :ref:`early-feedback` section.110 111+Kenneth Reitz's Code Style™112+~~~~~~~~~~~~~~~~~~~~~~~~~~~113+114+The Requests codebase uses the `PEP 8`_ code style.115+116+In addition to the standards outlined in PEP 8, we have a few guidelines:117+118+- Line-length can exceed 79 characters, to 100, when convenient.119+- Line-length can exceed 100 characters, when doing otherwise would be *terribly* inconvenient.120+- Always use single-quoted strings (e.g. ``'#flatearth'``), unless a single-quote occurs within the string.121+122+Additionally, one of the styles that PEP8 recommends for `line continuations`_123+completely lacks all sense of taste, and is not to be permitted within124+the Requests codebase::125+126+ # Aligned with opening delimiter.127+ foo = long_function_name(var_one, var_two,128+ var_three, var_four)129+130+No. Just don't. Please.131+132+Docstrings are to follow the following syntaxes::133+134+ def the_earth_is_flat():135+ """NASA divided up the seas into thirty-three degrees."""136+ pass137+138+::139+140+ def fibonacci_spiral_tool():141+ """With my feet upon the ground I lose myself / between the sounds142+ and open wide to suck it in. / I feel it move across my skin. / I'm143+ reaching up and reaching out. / I'm reaching for the random or144+ whatever will bewilder me. / Whatever will bewilder me. / And145+ following our will and wind we may just go where no one's been. /146+ We'll ride the spiral to the end and may just go where no one's147+ been.148+149+ Spiral out. Keep going...150+ """151+ pass152+153+All functions, methods, and classes are to contain docstrings. Object data154+model methods (e.g. ``__repr__``) are typically the exception to this rule.155+156+Thanks for helping to make the world a better place!157+158+.. _PEP 8: http://pep8.org159+.. _line continuations: https://www.python.org/dev/peps/pep-0008/#indentation160+161 Documentation Contributions162 ---------------------------163 164 Documentation improvements are always welcome! The documentation files live in165 the ``docs/`` directory of the codebase. They're written in166 `reStructuredText`_, and use `Sphinx`_ to generate the full suite of167 documentation.168 115-When contributing documentation, please attempt to follow the style of the169+When contributing documentation, please do your best to follow the style of the170 documentation files. This means a soft-limit of 79 characters wide in your text117-files and a semi-formal prose style.171+files and a semi-formal, yet friendly and approachable, prose style.172 173+When presenting Python code, use single-quoted strings (``'hello'`` instead of174+``"hello"``).175+176 .. _reStructuredText: http://docutils.sourceforge.net/rst.html177 .. _Sphinx: http://sphinx-doc.org/index.html178 179 12 unmodified lines192 193 Feature Requests194 ----------------195 139-Requests is in a perpetual feature freeze. The maintainers believe that140-requests contains every major feature currently required by the vast majority141-of users.196+Requests is in a perpetual feature freeze, only the BDFL can add or approve of197+new features. The maintainers believe that Requests is a feature-complete198+piece of software at this time.199 200+One of the most important skills to have while maintaining a largely-used201+open source project is learning the ability to say "no" to suggested changes,202+while keeping an open ear and mind.203+204 If you believe there is a feature missing, feel free to raise a feature205 request, but please do be aware that the overwhelming likelihood is that your145-feature request will not be accepted.206+feature request will not be accepted.modified:docs/user/advanced.rst+42 added-27 removed
22 unmodified lines23 24 s = requests.Session()25 26 s.get('http://httpbin.org/cookies/set/sessioncookie/123456789')27- r = s.get("http://httpbin.org/cookies")27+ r = s.get('http://httpbin.org/cookies')28 29 print(r.text)30 # '{"cookies": {"sessioncookie": "123456789"}}'31 17 unmodified lines49 requests, even if using a session. This example will only send the cookies50 with the first request, but not the second::51 52 s = requests.Session()53+54 r = s.get('http://httpbin.org/cookies', cookies={'from-my': 'browser'})55 print(r.text)56 # '{"cookies": {"from-my": "browser"}}'57 71 unmodified lines129 130 from requests import Request, Session131 132 s = Session()132- req = Request('GET', url,133- data=data,134- headers=header135- )133+134+ req = Request('POST', url, data=data, headers=headers)135 prepped = req.prepare()136 137 # do something with prepped.body138+ prepped.body = 'No, I want exactly this as the body.'139+140 # do something with prepped.headers141+ del prepped.headers['Content-Type']142 143 resp = s.send(prepped,144 stream=stream,145 verify=verify,20 unmodified lines166 167 from requests import Request, Session168 169 s = Session()168- req = Request('GET', url,169- data=data170- headers=headers171- )170+ req = Request('GET', url, data=data, headers=headers)171 172 prepped = s.prepare_request(req)173 174 # do something with prepped.body175+ prepped.body = 'Seriously, send exactly these bytes.'176+177 # do something with prepped.headers178+ prepped.headers['Keep-Dead'] = 'parrot'179 180 resp = s.send(prepped,181 stream=stream,182 verify=verify,174 unmodified lines357 POST Multiple Multipart-Encoded Files358 -------------------------------------359 360 You can send multiple files in one request. For example, suppose you want to359-upload image files to an HTML form with a multiple file field 'images':361+upload image files to an HTML form with a multiple file field 'images'::362 363 <input type="file" name="images" multiple="true" required="true"/>364 363-To do that, just set files to a list of tuples of (form_field_name, file_info):365+To do that, just set files to a list of tuples of ``(form_field_name, file_info)``::366 367 >>> url = 'http://httpbin.org/post'368+ >>> multiple_files = [366- >>> multiple_files = [('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),367- ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]369+ ('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),370+ ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]371 >>> r = requests.post(url, files=multiple_files)372 >>> r.text373 {374 ...118 unmodified lines493 the resulting iterator object instead::494 495 lines = r.iter_lines()496 # Save the first line for later or just skip it497+498 first_line = next(lines)499+500 for line in lines:501 print(line)502 503 .. _proxies:6 unmodified lines510 511 import requests512 513 proxies = {509- "http": "http://10.10.1.10:3128",510- "https": "http://10.10.1.10:1080",514+ 'http': 'http://10.10.1.10:3128',515+ 'https': 'http://10.10.1.10:1080',516 }517 513- requests.get("http://example.org", proxies=proxies)518+ requests.get('http://example.org', proxies=proxies)519 520 You can also configure proxies by setting the environment variables521 ``HTTP_PROXY`` and ``HTTPS_PROXY``.522 523 ::524 525 $ export HTTP_PROXY="http://10.10.1.10:3128"526 $ export HTTPS_PROXY="http://10.10.1.10:1080"527+528 $ python529 >>> import requests524- >>> requests.get("http://example.org")530+ >>> requests.get('http://example.org')531 532 To use HTTP Basic Auth with your proxy, use the `http://user:password@host/` syntax::533 528- proxies = {529- "http": "http://user:pass@10.10.1.10:3128/",530- }534+ proxies = {'http': 'http://user:pass@10.10.1.10:3128/'}535 536 To give a proxy for a specific scheme and host, use the537 `scheme://hostname` form for the key. This will match for538 any request to the given scheme and exact hostname.539 540 ::541 538- proxies = {539- "http://10.20.1.128": "http://10.10.1.10:5323",540- }542+ proxies = {'http://10.20.1.128': 'http://10.10.1.10:5323'}543 544 Note that proxy URLs must include the scheme.545 546 .. _compliance:56 unmodified lines603 604 ::605 606 >>> commit_data = r.json()607+608 >>> print(commit_data.keys())609 [u'committer', u'author', u'url', u'tree', u'sha', u'parents', u'message']610+611 >>> print(commit_data[u'committer'])612 {u'date': u'2012-05-10T11:10:50-07:00', u'email': u'me@kennethreitz.com', u'name': u'Kenneth Reitz'}613+614 >>> print(commit_data[u'message'])615 makin' history616 617 So far, so simple. Well, let's investigate the GitHub API a little bit. Now,31 unmodified lines649 650 >>> r = requests.get('https://api.github.com/repos/kennethreitz/requests/issues/482')651 >>> r.status_code652 200653+654 >>> issue = json.loads(r.text)655+656 >>> print(issue[u'title'])657 Feature any http verb in docs658+659 >>> print(issue[u'comments'])660 3661 662 Cool, we have three comments. Let's take a look at the last of them.2 unmodified lines665 666 >>> r = requests.get(r.url + u'/comments')667 >>> r.status_code668 200669+670 >>> comments = r.json()671+672 >>> print(comments[0].keys())673 [u'body', u'url', u'created_at', u'updated_at', u'user', u'id']674+675 >>> print(comments[2][u'body'])676 Probably in the "advanced" section677 678 Well, that seems like a silly place. Let's post a comment telling the poster11 unmodified lines690 ::691 692 >>> body = json.dumps({u"body": u"Sounds great! I'll get right on it!"})693 >>> url = u"https://api.github.com/repos/kennethreitz/requests/issues/482/comments"694+695 >>> r = requests.post(url=url, data=body)696 >>> r.status_code697 404698 4 unmodified lines703 ::704 705 >>> from requests.auth import HTTPBasicAuth706 >>> auth = HTTPBasicAuth('fake@example.com', 'not_a_real_password')707+708 >>> r = requests.post(url=url, data=body, auth=auth)709 >>> r.status_code710 201711+712 >>> content = r.json()713 >>> print(content[u'body'])714 Sounds great! I'll get right on it.715 5 unmodified lines721 ::722 723 >>> print(content[u"id"])724 5804413725+726 >>> body = json.dumps({u"body": u"Sounds great! I'll get right on it once I feed my cat."})727 >>> url = u"https://api.github.com/repos/kennethreitz/requests/issues/comments/5804413"728+729 >>> r = requests.patch(url=url, data=body, auth=auth)730 >>> r.status_code731 200732 112 unmodified lines845 class Ssl3HttpAdapter(HTTPAdapter):846 """"Transport adapter" that allows us to use SSLv3."""847 848 def init_poolmanager(self, connections, maxsize, block=False):833- self.poolmanager = PoolManager(num_pools=connections,834- maxsize=maxsize,835- block=block,836- ssl_version=ssl.PROTOCOL_SSLv3)849+ self.poolmanager = PoolManager(850+ num_pools=connections, maxsize=maxsize,851+ block=block, ssl_version=ssl.PROTOCOL_SSLv3)852 853 .. _`described here`: http://www.kennethreitz.org/essays/the-future-of-python-http854 .. _`urllib3`: https://github.com/shazow/urllib3855 58 unmodified linesmodified:docs/user/install.rst+12 added-20 removed
5 unmodified lines6 This part of the documentation covers the installation of Requests.7 The first step to using any software package is getting it properly installed.8 9 10-Distribute & Pip11-----------------10+Pip Install Requests11+--------------------12 13-Installing Requests is simple with `pip <https://pip.pypa.io>`_, just run14-this in your terminal::13+To install Requests, simply run this simple command in your terminal of choice::14 15 $ pip install requests16 18-or, with `easy_install <http://pypi.python.org/pypi/setuptools>`_::17+If 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/>`_19+can guide you through the process.20 20- $ easy_install requests21+Get the Source Code22+-------------------23 22-But, you really `shouldn't do that <https://stackoverflow.com/questions/3220404/why-use-pip-over-easy-install>`_.23-24-25-Get the Code26-------------27-24 Requests is actively developed on GitHub, where the code is25 `always available <https://github.com/kennethreitz/requests>`_.26 27 You can either clone the public repository::28 29 $ git clone git://github.com/kennethreitz/requests.git30 35-Download the `tarball <https://github.com/kennethreitz/requests/tarball/master>`_::31+Or, download the `tarball <https://github.com/kennethreitz/requests/tarball/master>`_::32 33 $ curl -OL https://github.com/kennethreitz/requests/tarball/master34+ # optionally, zipball is also available (for Windows users).35 39-Or, download the `zipball <https://github.com/kennethreitz/requests/zipball/master>`_::36+Once you have a copy of the source, you can embed it in your own Python37+package, or install it into your site-packages easily::38 41- $ curl -OL https://github.com/kennethreitz/requests/zipball/master42-43-44-Once you have a copy of the source, you can embed it in your Python package,45-or install it into your site-packages easily::46-39 $ python setup.py installmodified:docs/user/quickstart.rst+22 added-8 removed
35 unmodified lines36 37 Requests' simple API means that all forms of HTTP request are as obvious. For38 example, this is how you make an HTTP POST request::39 40- >>> r = requests.post("http://httpbin.org/post", data = {"key":"value"})40+ >>> r = requests.post('http://httpbin.org/post', data = {'key':'value'})41 42 Nice, right? What about the other HTTP request types: PUT, DELETE, HEAD and43 OPTIONS? These are all just as simple::44 45- >>> 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")45+ >>> 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')49 50 That's all well and good, but it's also only the start of what Requests can51 do.52 9 unmodified lines62 ``key1=value1`` and ``key2=value2`` to ``httpbin.org/get``, you would use the63 following code::64 65 >>> payload = {'key1': 'value1', 'key2': 'value2'}66- >>> r = requests.get("http://httpbin.org/get", params=payload)66+ >>> r = requests.get('http://httpbin.org/get', params=payload)67 68 You can see that the URL has been correctly encoded by printing the URL::69 70 >>> print(r.url)4 unmodified lines75 76 You can also pass a list of items as a value::77 78 >>> payload = {'key1': 'value1', 'key2': ['value2', 'value3']}79+79- >>> r = requests.get("http://httpbin.org/get", params=payload)80+ >>> r = requests.get('http://httpbin.org/get', params=payload)81 >>> print(r.url)82 http://httpbin.org/get?key1=value1&key2=value2&key2=value383 84 Response Content2 unmodified lines87 We can read the content of the server's response. Consider the GitHub timeline88 again::89 90 >>> import requests91+92 >>> r = requests.get('https://api.github.com/events')93 >>> r.text94 u'[{"repository":{"open_issues":0,"url":"https://github.com/...95 36 unmodified lines132 use the following code::133 134 >>> from PIL import Image135 >>> from StringIO import StringIO136+137 >>> i = Image.open(StringIO(r.content))138 139 140 JSON Response Content1 unmodified line142 143 There's also a builtin JSON decoder, in case you're dealing with JSON data::144 145 >>> import requests146+147 >>> r = requests.get('https://api.github.com/events')148 >>> r.json()149 [{u'repository': {u'open_issues': 0, u'url': 'https://github.com/...150 15 unmodified lines166 server, you can access ``r.raw``. If you want to do this, make sure you set167 ``stream=True`` in your initial request. Once you do, you can do this::168 169 >>> r = requests.get('https://api.github.com/events', stream=True)170+171 >>> r.raw172 <requests.packages.urllib3.response.HTTPResponse object at 0x101194810>173+174 >>> r.raw.read(10)175 '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03'176 177 In general, however, you should use a pattern like this to save what is being16 unmodified lines194 ``headers`` parameter.195 196 For example, we didn't specify our user-agent in the previous example::197 192- >>> import json198 >>> url = 'https://api.github.com/some/endpoint'199 >>> headers = {'user-agent': 'my-app/0.0.1'}200 201 >>> r = requests.get(url, headers=headers)17 unmodified lines219 To do this, simply pass a dictionary to the ``data`` argument. Your220 dictionary of data will automatically be form-encoded when the request is made::221 222 >>> payload = {'key1': 'value1', 'key2': 'value2'}223+224 >>> r = requests.post("http://httpbin.org/post", data=payload)225 >>> print(r.text)226 {227 ...9 unmodified lines237 238 For example, the GitHub API v3 accepts JSON-Encoded POST/PATCH data::239 240 >>> import json241+242 >>> url = 'https://api.github.com/some/endpoint'243 >>> payload = {'some': 'data'}244 245 >>> r = requests.post(url, data=json.dumps(payload))186 unmodified lines432 433 For example, GitHub redirects all HTTP requests to HTTPS::434 435 >>> r = requests.get('http://github.com')436+437 >>> r.url438 'https://github.com/'439+440 >>> r.status_code441 200442+443 >>> r.history444 [<Response [301]>]445 446 447 If you're using GET, OPTIONS, POST, PUT, PATCH or DELETE, you can disable448 redirection handling with the ``allow_redirects`` parameter::449 450 >>> r = requests.get('http://github.com', allow_redirects=False)451+452 >>> r.status_code453 301454+455 >>> r.history456 []457 458 If you're using HEAD, you can enable redirection as well::459 460 >>> r = requests.head('http://github.com', allow_redirects=True)461+462 >>> r.url463 'https://github.com/'464+465 >>> r.history466 [<Response [301]>]467 468 41 unmodified linesmodified:docs/api.rst+42 added-49 removed
23 unmodified lines24 .. autofunction:: put25 .. autofunction:: patch26 .. autofunction:: delete27 28+Exceptions29+----------30 31+.. autoexception:: requests.RequestException32+.. autoexception:: requests.ConnectionError33+.. autoexception:: requests.HTTPError34+.. autoexception:: requests.URLRequired35+.. autoexception:: requests.TooManyRedirects36+.. autoexception:: requests.ConnectTimeout37+.. autoexception:: requests.ReadTimeout38+.. autoexception:: requests.Timeout39+40+41+Request Sessions42+----------------43+44+.. _sessionapi:45+46+.. autoclass:: Session47+ :inherited-members:48+49+50 Lower-Level Classes30-~~~~~~~~~~~~~~~~~~~51+-------------------52 53 .. autoclass:: requests.Request54 :inherited-members:55 56 .. autoclass:: Response57 :inherited-members:58 38-Request Sessions39-----------------59 41-.. autoclass:: Session60+Lower-Lower-Level Classes61+-------------------------62+63+.. autoclass:: requests.PreparedRequest64 :inherited-members:65 66 .. autoclass:: requests.adapters.HTTPAdapter67 :inherited-members:5 unmodified lines73 .. autoclass:: requests.auth.HTTPBasicAuth74 .. autoclass:: requests.auth.HTTPProxyAuth75 .. autoclass:: requests.auth.HTTPDigestAuth76 55-Exceptions56-~~~~~~~~~~77 58-.. autoexception:: requests.exceptions.RequestException59-.. autoexception:: requests.exceptions.ConnectionError60-.. autoexception:: requests.exceptions.HTTPError61-.. autoexception:: requests.exceptions.URLRequired62-.. autoexception:: requests.exceptions.TooManyRedirects63-.. autoexception:: requests.exceptions.ConnectTimeout64-.. autoexception:: requests.exceptions.ReadTimeout65-.. autoexception:: requests.exceptions.Timeout78 79+Encodings80+---------81 68-Status Code Lookup69-~~~~~~~~~~~~~~~~~~82+.. autofunction:: requests.utils.get_encodings_from_content83+.. autofunction:: requests.utils.get_encoding_from_headers84+.. autofunction:: requests.utils.get_unicode_from_response85 71-.. autofunction:: requests.codes86 73-::74-75- >>> requests.codes['temporary_redirect']76- 30777-78- >>> requests.codes.teapot79- 41880-81- >>> requests.codes['\o/']82- 20083-87 .. _api-cookies:88 89 Cookies87-~~~~~~~90+-------91 92 .. autofunction:: requests.utils.dict_from_cookiejar93 .. autofunction:: requests.utils.cookiejar_from_dict94 .. autofunction:: requests.utils.add_dict_to_cookiejar4 unmodified lines99 .. autoclass:: requests.cookies.CookieConflictError100 :inherited-members:101 102 100-Encodings101-~~~~~~~~~103 103-.. autofunction:: requests.utils.get_encodings_from_content104-.. autofunction:: requests.utils.get_encoding_from_headers105-.. autofunction:: requests.utils.get_unicode_from_response104+Status Code Lookup105+------------------106 107+.. autoclass:: requests.codes108 108-Classes109-~~~~~~~109+::110 111-.. autoclass:: requests.Response112- :inherited-members:111+ >>> requests.codes['temporary_redirect']112+ 307113 114-.. autoclass:: requests.Request115- :inherited-members:114+ >>> requests.codes.teapot115+ 418116 117-.. autoclass:: requests.PreparedRequest118- :inherited-members:117+ >>> requests.codes['\o/']118+ 200119 120-.. _sessionapi:120 122-.. autoclass:: requests.Session123- :inherited-members:121 125-.. autoclass:: requests.adapters.HTTPAdapter126- :inherited-members:127-128-122 Migrating to 1.x123 ----------------124 125 This section details the main differences between 0.x and 1.x and is meant138 unmodified linesmodified:docs/conf.py+169 added-46 removed
1 # -*- coding: utf-8 -*-2 #3 # Requests documentation build configuration file, created by4-# sphinx-quickstart on Sun Feb 13 23:54:25 2011.4+# sphinx-quickstart on Fri Feb 19 00:05:47 2016.5 #6-# This file is execfile()d with the current directory set to its containing dir.6+# This file is execfile()d with the current directory set to its7+# containing dir.8 #9 # Note that not all possible configuration values are present in this10 # autogenerated file.11 #12 # All configuration values have a default; values that are commented out13 # serve to show the default.14 14-import sys, os15+import sys16+import os17 18 # If extensions (or modules to document with autodoc) are in another directory,19 # add these directories to sys.path here. If the directory is relative to the20 # documentation root, use os.path.abspath to make it absolute, like shown here.21+#sys.path.insert(0, os.path.abspath('.'))22+23+# Insert Requests' path into the system.24 sys.path.insert(0, os.path.abspath('..'))25+sys.path.insert(0, os.path.abspath('_themes'))26+27 import requests28 from requests import __version__29 23-import alabaster30 25-# -- General configuration -----------------------------------------------------31+# -- General configuration ------------------------------------------------32 33 # If your documentation needs a minimal Sphinx version, state it here.34 #needs_sphinx = '1.0'35 30-# Add any Sphinx extension module names here, as strings. They can be extensions31-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.36+# Add any Sphinx extension module names here, as strings. They can be37+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom38+# ones.39 extensions = [40 'sphinx.ext.autodoc',41 'sphinx.ext.intersphinx',35- 'alabaster'42+ 'sphinx.ext.todo',43+ 'sphinx.ext.viewcode',44 ]45 46 # Add any paths that contain templates here, relative to this directory.47 templates_path = ['_templates']48 41-# The suffix of source filenames.49+# The suffix(es) of source filenames.50+# You can specify multiple suffix as a list of string:51+# source_suffix = ['.rst', '.md']52 source_suffix = '.rst'53 54 # The encoding of source files.55 #source_encoding = 'utf-8-sig'3 unmodified lines59 60 # General information about the project.61 project = u'Requests'62 copyright = u'2016. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project'63+author = u'Kenneth Reitz'64 65 # The version info for the project you're documenting, acts as replacement for66 # |version| and |release|, also used in various other places throughout the67 # built documents.68 #69 # The short X.Y version.70 version = __version__71 # The full version, including alpha/beta/rc tags.61-release = version72+release = __version__73 74 # The language for content autogenerated by Sphinx. Refer to documentation75 # for a list of supported languages.76+#77+# This is also used if you do content translation via gettext catalogs.78+# Usually you set "language" from the command line for these cases.65-#language = None79+language = None80 81 # There are two options for replacing |today|: either, you set today to some82 # non-false value, then it is used:83 #today = ''3 unmodified lines87 # List of patterns, relative to source directory, that match files and88 # directories to ignore when looking for source files.89 exclude_patterns = ['_build']90 77-# The reST default role (used for this markup: `text`) to use for all documents.91+# The reST default role (used for this markup: `text`) to use for all92+# documents.93 #default_role = None94 95 # If true, '()' will be appended to :func: etc. cross-reference text.81-#add_function_parentheses = True96+add_function_parentheses = False97 98 # If true, the current module name will be prepended to all description99 # unit titles (such as .. function::).85-#add_module_names = True100+add_module_names = True101 102 # If true, sectionauthor and moduleauthor directives will be shown in the103 # output. They are ignored by default.104 #show_authors = False3 unmodified lines108 109 # A list of ignored prefixes for module index sorting.110 #modindex_common_prefix = []111 112+# If true, keep warnings as "system message" paragraphs in the built documents.113+#keep_warnings = False114 98-# -- Options for HTML output ---------------------------------------------------115+# If true, `todo` and `todoList` produce output, else they produce nothing.116+todo_include_todos = True117 118+119+# -- Options for HTML output ----------------------------------------------120+121 # The theme to use for HTML and HTML Help pages. See the documentation for122 # a list of builtin themes.102-html_theme = 'default'123+html_theme = 'alabaster'124 125 # Theme options are theme-specific and customize the look and feel of a theme126 # further. For a list of options available for each theme, see the127 # documentation.128 html_theme_options = {108- 'show_powered_by': False,109- 'github_user': 'kennethreitz',110- 'github_repo': 'requests',111- 'github_banner': True129+ 'show_powered_by': False,130+ 'github_user': 'kennethreitz',131+ 'github_repo': 'requests',132+ 'github_banner': True,133+ 'show_related': False134 }135 136 # Add any paths that contain custom themes here, relative to this directory.137 #html_theme_path = []8 unmodified lines146 # The name of an image file (relative to this directory) to place at the top147 # of the sidebar.148 #html_logo = None149 128-150 # The name of an image file (within the static path) to use as favicon of the151 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32152 # pixels large.153 #html_favicon = None2 unmodified lines156 # relative to this directory. They are copied after the builtin static files,157 # so a file named "default.css" will overwrite the builtin "default.css".158 html_static_path = ['_static']159 160+# Add any extra paths that contain custom files (such as robots.txt or161+# .htaccess) here, relative to this directory. These files are copied162+# directly to the root of the documentation.163+#html_extra_path = []164+165 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,166 # using the given strftime format.167 #html_last_updated_fmt = '%b %d, %Y'168 169 # If true, SmartyPants will be used to convert quotes and dashes to170 # typographically correct entities.145-#html_use_smartypants = True171+html_use_smartypants = False172 173 # Custom sidebar templates, maps document names to template names.174 html_sidebars = {149- 'index': ['sidebarintro.html', 'sourcelink.html', 'searchbox.html'],175+ 'index': ['sidebarintro.html', 'sourcelink.html', 'searchbox.html',176+ 'hacks.html'],177 '**': ['sidebarlogo.html', 'localtoc.html', 'relations.html',151- 'sourcelink.html', 'searchbox.html']178+ 'sourcelink.html', 'searchbox.html', 'hacks.html']179 }180 181 # Additional templates that should be rendered to pages, maps page names to182 # template names.14 unmodified lines197 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.198 html_show_sphinx = False199 200 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.174-#html_show_copyright = True201+html_show_copyright = True202 203 # If true, an OpenSearch description file will be output, and all pages will204 # contain a <link> tag referring to it. The value of this option must be the205 # base URL from which the finished HTML is served.1 unmodified line207 208 # This is the file name suffix for HTML files (e.g. ".xhtml").209 #html_file_suffix = None210 211+# Language to be used for generating the HTML full-text search index.212+# Sphinx supports the following languages:213+# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'214+# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'215+#html_search_language = 'en'216+217+# A dictionary with options for the search language support, empty by default.218+# Now only 'ja' uses this config value219+#html_search_options = {'type': 'default'}220+221+# The name of a javascript file (relative to the configuration directory) that222+# implements a search results scorer. If empty, the default will be used.223+#html_search_scorer = 'scorer.js'224+225 # Output file base name for HTML help builder.226 htmlhelp_basename = 'Requestsdoc'227 228+# -- Options for LaTeX output ---------------------------------------------229 188-# -- Options for LaTeX output --------------------------------------------------230+latex_elements = {231+# The paper size ('letterpaper' or 'a4paper').232+#'papersize': 'letterpaper',233 190-# The paper size ('letter' or 'a4').191-#latex_paper_size = 'letter'192-234 # The font size ('10pt', '11pt' or '12pt').194-#latex_font_size = '10pt'235+#'pointsize': '10pt',236 237+# Additional stuff for the LaTeX preamble.238+#'preamble': '',239+240+# Latex figure (float) alignment241+#'figure_align': 'htbp',242+}243+244 # Grouping the document tree into LaTeX files. List of tuples197-# (source start file, target name, title, author, documentclass [howto/manual]).245+# (source start file, target name, title,246+# author, documentclass [howto, manual, or own class]).247 latex_documents = [199- ('index', 'Requests.tex', u'Requests Documentation',200- u'Kenneth Reitz', 'manual'),248+ (master_doc, 'Requests.tex', u'Requests Documentation',249+ u'Kenneth Reitz', 'manual'),250 ]251 252 # The name of an image file (relative to this directory) to place at the top of253 # the title page.8 unmodified lines262 263 # If true, show URL addresses after external links.264 #latex_show_urls = False265 217-# Additional stuff for the LaTeX preamble.218-#latex_preamble = ''219-266 # Documents to append as an appendix to all manuals.267 #latex_appendices = []268 269 # If false, no module index is generated.270 #latex_domain_indices = True271 272 227-# -- Options for manual page output --------------------------------------------273+# -- Options for manual page output ---------------------------------------274 275 # One entry per manual page. List of tuples276 # (source start file, name, description, authors, manual section).277 man_pages = [232- ('index', 'requests', u'Requests Documentation',233- [u'Kenneth Reitz'], 1)278+ (master_doc, 'requests', u'Requests Documentation',279+ [author], 1)280 ]281 282 # If true, show URL addresses after external links.283 #man_show_urls = False284 239-# -- Options for Texinfo output ------------------------------------------------285 286+# -- Options for Texinfo output -------------------------------------------287+288 # Grouping the document tree into Texinfo files. List of tuples289 # (source start file, target name, title, author,290 # dir menu entry, description, category)291 texinfo_documents = [245- ('index', 'Requests', u'Requests Documentation', u'Kenneth Reitz',246- 'Requests', 'One line description of project.', 'Miscellaneous'),292+ (master_doc, 'Requests', u'Requests Documentation',293+ author, 'Requests', 'One line description of project.',294+ 'Miscellaneous'),295 ]296 297 # Documents to append as an appendix to all manuals.250-texinfo_appendices = []298+#texinfo_appendices = []299 252-sys.path.append(os.path.abspath('_themes'))253-html_theme_path =[alabaster.get_path()]254-html_theme = 'alabaster'300+# If false, no module index is generated.301+#texinfo_domain_indices = True302 303+# How to display URL addresses: 'footnote', 'no', or 'inline'.304+#texinfo_show_urls = 'footnote'305+306+# If true, do not generate a @detailmenu in the "Top" node's menu.307+#texinfo_no_detailmenu = False308+309+310+# -- Options for Epub output ----------------------------------------------311+312+# Bibliographic Dublin Core info.313+epub_title = project314+epub_author = author315+epub_publisher = author316+epub_copyright = copyright317+318+# The basename for the epub file. It defaults to the project name.319+#epub_basename = project320+321+# The HTML theme for the epub output. Since the default themes are not322+# optimized for small screen space, using the same theme for HTML and epub323+# output is usually not wise. This defaults to 'epub', a theme designed to save324+# visual space.325+#epub_theme = 'epub'326+327+# The language of the text. It defaults to the language option328+# or 'en' if the language is not set.329+#epub_language = ''330+331+# The scheme of the identifier. Typical schemes are ISBN or URL.332+#epub_scheme = ''333+334+# The unique identifier of the text. This can be a ISBN number335+# or the project homepage.336+#epub_identifier = ''337+338+# A unique identification for the text.339+#epub_uid = ''340+341+# A tuple containing the cover image and cover page html template filenames.342+#epub_cover = ()343+344+# A sequence of (type, uri, title) tuples for the guide element of content.opf.345+#epub_guide = ()346+347+# HTML files that should be inserted before the pages created by sphinx.348+# The format is a list of tuples containing the path and title.349+#epub_pre_files = []350+351+# HTML files that should be inserted after the pages created by sphinx.352+# The format is a list of tuples containing the path and title.353+#epub_post_files = []354+355+# A list of files that should not be packed into the epub file.356+epub_exclude_files = ['search.html']357+358+# The depth of the table of contents in toc.ncx.359+#epub_tocdepth = 3360+361+# Allow duplicate toc entries.362+#epub_tocdup = True363+364+# Choose between 'default' and 'includehidden'.365+#epub_tocscope = 'default'366+367+# Fix unsupported image types using the Pillow.368+#epub_fix_images = False369+370+# Scale large images.371+#epub_max_image_width = 0372+373+# How to display URL addresses: 'footnote', 'no', or 'inline'.374+#epub_show_urls = 'inline'375+376+# If false, no index is generated.377+#epub_use_index = True378+379 intersphinx_mapping = {'urllib3': ('http://urllib3.readthedocs.org/en/latest', None)}modified:docs/index.rst+17 added-14 removed
36 unmodified lines37 URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling38 are 100% automatic, powered by `urllib3 <https://github.com/shazow/urllib3>`_,39 which is embedded within Requests.40 41-Testimonials42-------------41+User Testimonials42+-----------------43 44 Her Majesty's Government, Amazon, Google, Twilio, Runscope, Mozilla, Heroku,45 PayPal, NPR, Obama for America, Transifex, Native Instruments, The Washington46 Post, Twitter, SoundCloud, Kippt, Readability, Sony, and Federal U.S.17 unmodified lines64 65 Requests is one of the most downloaded Python packages of all time, pulling in66 over 7,000,000 downloads every month. All the cool kids are doing it!67 68-Feature Support69----------------68+Supported Features69+------------------70 71 Requests is ready for today's web.72 73 - International Domains and URLs15 unmodified lines89 90 Requests supports Python 2.6 — 3.5, and runs great on PyPy.91 92 93-User Guide94-----------93+The User Guide94+--------------95 96 This part of the documentation, which is mostly prose, begins with some97 background information about Requests, then focuses on step-by-step98 instructions for getting the most out of Requests.7 unmodified lines106 user/advanced107 user/authentication108 109 110-Community Guide111------------------110+The Community Guide111+-------------------112 113 This part of the documentation, which is mostly prose, details the114 Requests ecosystem and community.115 7 unmodified lines123 community/vulnerabilities124 community/updates125 community/release-process126 127-API Documentation128------------------127+The API Documentation / Guide128+-----------------------------129 130-If you are looking for information on a specific function, class or method,130+If you are looking for information on a specific function, class, or method,131 this part of the documentation is for you.132 133 .. toctree::134 :maxdepth: 2135 136 api137 138 139-Contributor Guide140------------------139+The Contributor Guide140+---------------------141 142 If you want to contribute to the project, this part of the documentation is for143 you.144 145 .. toctree::146- :maxdepth: 1146+ :maxdepth: 3147 148 dev/contributing149 dev/philosophy150 dev/todo151 dev/authors152+153+There are no more guides. You are now guideless.154+Good luck.modified:docs/make.bat+263 added-190 removed
1-@ECHO OFF2-3-REM Command file for Sphinx documentation4-5-if "%SPHINXBUILD%" == "" (6- set SPHINXBUILD=sphinx-build7-)8-set BUILDDIR=_build9-set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .10-set I18NSPHINXOPTS=%SPHINXOPTS% .11-if NOT "%PAPER%" == "" (12- set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%13- set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%14-)15-16-if "%1" == "" goto help17-18-if "%1" == "help" (19- :help20- echo.Please use `make ^<target^>` where ^<target^> is one of21- echo. html to make standalone HTML files22- echo. dirhtml to make HTML files named index.html in directories23- echo. singlehtml to make a single large HTML file24- echo. pickle to make pickle files25- echo. json to make JSON files26- echo. htmlhelp to make HTML files and a HTML help project27- echo. qthelp to make HTML files and a qthelp project28- echo. devhelp to make HTML files and a Devhelp project29- echo. epub to make an epub30- echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter31- echo. text to make text files32- echo. man to make manual pages33- echo. texinfo to make Texinfo files34- echo. gettext to make PO message catalogs35- echo. changes to make an overview over all changed/added/deprecated items36- echo. linkcheck to check all external links for integrity37- echo. doctest to run all doctests embedded in the documentation if enabled38- goto end39-)40-41-if "%1" == "clean" (42- for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i43- del /q /s %BUILDDIR%\*44- goto end45-)46-47-if "%1" == "html" (48- %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html49- if errorlevel 1 exit /b 150- echo.51- echo.Build finished. The HTML pages are in %BUILDDIR%/html.52- goto end53-)54-55-if "%1" == "dirhtml" (56- %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml57- if errorlevel 1 exit /b 158- echo.59- echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.60- goto end61-)62-63-if "%1" == "singlehtml" (64- %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml65- if errorlevel 1 exit /b 166- echo.67- echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.68- goto end69-)70-71-if "%1" == "pickle" (72- %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle73- if errorlevel 1 exit /b 174- echo.75- echo.Build finished; now you can process the pickle files.76- goto end77-)78-79-if "%1" == "json" (80- %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json81- if errorlevel 1 exit /b 182- echo.83- echo.Build finished; now you can process the JSON files.84- goto end85-)86-87-if "%1" == "htmlhelp" (88- %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp89- if errorlevel 1 exit /b 190- echo.91- echo.Build finished; now you can run HTML Help Workshop with the ^92-.hhp project file in %BUILDDIR%/htmlhelp.93- goto end94-)95-96-if "%1" == "qthelp" (97- %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp98- if errorlevel 1 exit /b 199- echo.100- echo.Build finished; now you can run "qcollectiongenerator" with the ^101-.qhcp project file in %BUILDDIR%/qthelp, like this:102- echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Requests.qhcp103- echo.To view the help file:104- echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Requests.ghc105- goto end106-)107-108-if "%1" == "devhelp" (109- %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp110- if errorlevel 1 exit /b 1111- echo.112- echo.Build finished.113- goto end114-)115-116-if "%1" == "epub" (117- %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub118- if errorlevel 1 exit /b 1119- echo.120- echo.Build finished. The epub file is in %BUILDDIR%/epub.121- goto end122-)123-124-if "%1" == "latex" (125- %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex126- if errorlevel 1 exit /b 1127- echo.128- echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.129- goto end130-)131-132-if "%1" == "text" (133- %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text134- if errorlevel 1 exit /b 1135- echo.136- echo.Build finished. The text files are in %BUILDDIR%/text.137- goto end138-)139-140-if "%1" == "man" (141- %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man142- if errorlevel 1 exit /b 1143- echo.144- echo.Build finished. The manual pages are in %BUILDDIR%/man.145- goto end146-)147-148-if "%1" == "texinfo" (149- %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo150- if errorlevel 1 exit /b 1151- echo.152- echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.153- goto end154-)155-156-if "%1" == "gettext" (157- %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale158- if errorlevel 1 exit /b 1159- echo.160- echo.Build finished. The message catalogs are in %BUILDDIR%/locale.161- goto end162-)163-164-if "%1" == "changes" (165- %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes166- if errorlevel 1 exit /b 1167- echo.168- echo.The overview file is in %BUILDDIR%/changes.169- goto end170-)171-172-if "%1" == "linkcheck" (173- %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck174- if errorlevel 1 exit /b 1175- echo.176- echo.Link check complete; look for any errors in the above output ^177-or in %BUILDDIR%/linkcheck/output.txt.178- goto end179-)180-181-if "%1" == "doctest" (182- %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest183- if errorlevel 1 exit /b 1184- echo.185- echo.Testing of doctests in the sources finished, look at the ^186-results in %BUILDDIR%/doctest/output.txt.187- goto end188-)189-190-:end1+@ECHO OFF2+3+REM Command file for Sphinx documentation4+5+if "%SPHINXBUILD%" == "" (6+ set SPHINXBUILD=sphinx-build7+)8+set BUILDDIR=_build9+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .10+set I18NSPHINXOPTS=%SPHINXOPTS% .11+if NOT "%PAPER%" == "" (12+ set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%13+ set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%14+)15+16+if "%1" == "" goto help17+18+if "%1" == "help" (19+ :help20+ echo.Please use `make ^<target^>` where ^<target^> is one of21+ echo. html to make standalone HTML files22+ echo. dirhtml to make HTML files named index.html in directories23+ echo. singlehtml to make a single large HTML file24+ echo. pickle to make pickle files25+ echo. json to make JSON files26+ echo. htmlhelp to make HTML files and a HTML help project27+ echo. qthelp to make HTML files and a qthelp project28+ echo. devhelp to make HTML files and a Devhelp project29+ echo. epub to make an epub30+ echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter31+ echo. text to make text files32+ echo. man to make manual pages33+ echo. texinfo to make Texinfo files34+ echo. gettext to make PO message catalogs35+ echo. changes to make an overview over all changed/added/deprecated items36+ echo. xml to make Docutils-native XML files37+ echo. pseudoxml to make pseudoxml-XML files for display purposes38+ echo. linkcheck to check all external links for integrity39+ echo. doctest to run all doctests embedded in the documentation if enabled40+ echo. coverage to run coverage check of the documentation if enabled41+ goto end42+)43+44+if "%1" == "clean" (45+ for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i46+ del /q /s %BUILDDIR%\*47+ goto end48+)49+50+51+REM Check if sphinx-build is available and fallback to Python version if any52+%SPHINXBUILD% 1>NUL 2>NUL53+if errorlevel 9009 goto sphinx_python54+goto sphinx_ok55+56+:sphinx_python57+58+set SPHINXBUILD=python -m sphinx.__init__59+%SPHINXBUILD% 2> nul60+if errorlevel 9009 (61+ echo.62+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx63+ echo.installed, then set the SPHINXBUILD environment variable to point64+ echo.to the full path of the 'sphinx-build' executable. Alternatively you65+ echo.may add the Sphinx directory to PATH.66+ echo.67+ echo.If you don't have Sphinx installed, grab it from68+ echo.http://sphinx-doc.org/69+ exit /b 170+)71+72+:sphinx_ok73+74+75+if "%1" == "html" (76+ %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html77+ if errorlevel 1 exit /b 178+ echo.79+ echo.Build finished. The HTML pages are in %BUILDDIR%/html.80+ goto end81+)82+83+if "%1" == "dirhtml" (84+ %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml85+ if errorlevel 1 exit /b 186+ echo.87+ echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.88+ goto end89+)90+91+if "%1" == "singlehtml" (92+ %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml93+ if errorlevel 1 exit /b 194+ echo.95+ echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.96+ goto end97+)98+99+if "%1" == "pickle" (100+ %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle101+ if errorlevel 1 exit /b 1102+ echo.103+ echo.Build finished; now you can process the pickle files.104+ goto end105+)106+107+if "%1" == "json" (108+ %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json109+ if errorlevel 1 exit /b 1110+ echo.111+ echo.Build finished; now you can process the JSON files.112+ goto end113+)114+115+if "%1" == "htmlhelp" (116+ %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp117+ if errorlevel 1 exit /b 1118+ echo.119+ echo.Build finished; now you can run HTML Help Workshop with the ^120+.hhp project file in %BUILDDIR%/htmlhelp.121+ goto end122+)123+124+if "%1" == "qthelp" (125+ %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp126+ if errorlevel 1 exit /b 1127+ echo.128+ echo.Build finished; now you can run "qcollectiongenerator" with the ^129+.qhcp project file in %BUILDDIR%/qthelp, like this:130+ echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Requests.qhcp131+ echo.To view the help file:132+ echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Requests.ghc133+ goto end134+)135+136+if "%1" == "devhelp" (137+ %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp138+ if errorlevel 1 exit /b 1139+ echo.140+ echo.Build finished.141+ goto end142+)143+144+if "%1" == "epub" (145+ %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub146+ if errorlevel 1 exit /b 1147+ echo.148+ echo.Build finished. The epub file is in %BUILDDIR%/epub.149+ goto end150+)151+152+if "%1" == "latex" (153+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex154+ if errorlevel 1 exit /b 1155+ echo.156+ echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.157+ goto end158+)159+160+if "%1" == "latexpdf" (161+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex162+ cd %BUILDDIR%/latex163+ make all-pdf164+ cd %~dp0165+ echo.166+ echo.Build finished; the PDF files are in %BUILDDIR%/latex.167+ goto end168+)169+170+if "%1" == "latexpdfja" (171+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex172+ cd %BUILDDIR%/latex173+ make all-pdf-ja174+ cd %~dp0175+ echo.176+ echo.Build finished; the PDF files are in %BUILDDIR%/latex.177+ goto end178+)179+180+if "%1" == "text" (181+ %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text182+ if errorlevel 1 exit /b 1183+ echo.184+ echo.Build finished. The text files are in %BUILDDIR%/text.185+ goto end186+)187+188+if "%1" == "man" (189+ %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man190+ if errorlevel 1 exit /b 1191+ echo.192+ echo.Build finished. The manual pages are in %BUILDDIR%/man.193+ goto end194+)195+196+if "%1" == "texinfo" (197+ %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo198+ if errorlevel 1 exit /b 1199+ echo.200+ echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.201+ goto end202+)203+204+if "%1" == "gettext" (205+ %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale206+ if errorlevel 1 exit /b 1207+ echo.208+ echo.Build finished. The message catalogs are in %BUILDDIR%/locale.209+ goto end210+)211+212+if "%1" == "changes" (213+ %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes214+ if errorlevel 1 exit /b 1215+ echo.216+ echo.The overview file is in %BUILDDIR%/changes.217+ goto end218+)219+220+if "%1" == "linkcheck" (221+ %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck222+ if errorlevel 1 exit /b 1223+ echo.224+ echo.Link check complete; look for any errors in the above output ^225+or in %BUILDDIR%/linkcheck/output.txt.226+ goto end227+)228+229+if "%1" == "doctest" (230+ %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest231+ if errorlevel 1 exit /b 1232+ echo.233+ echo.Testing of doctests in the sources finished, look at the ^234+results in %BUILDDIR%/doctest/output.txt.235+ goto end236+)237+238+if "%1" == "coverage" (239+ %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage240+ if errorlevel 1 exit /b 1241+ echo.242+ echo.Testing of coverage in the sources finished, look at the ^243+results in %BUILDDIR%/coverage/python.txt.244+ goto end245+)246+247+if "%1" == "xml" (248+ %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml249+ if errorlevel 1 exit /b 1250+ echo.251+ echo.Build finished. The XML files are in %BUILDDIR%/xml.252+ goto end253+)254+255+if "%1" == "pseudoxml" (256+ %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml257+ if errorlevel 1 exit /b 1258+ echo.259+ echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.260+ goto end261+)262+263+:endmodified:docs/Makefile+67 added-4 removed
5 unmodified lines6 SPHINXBUILD = sphinx-build7 PAPER =8 BUILDDIR = _build9 10+# User-friendly check for sphinx-build11+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)12+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)13+endif14+15 # Internal variables.16 PAPEROPT_a4 = -D latex_paper_size=a417 PAPEROPT_letter = -D latex_paper_size=letter18 ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .19 # the i18n builder cannot share the environment and doctrees with the others20 I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .21 17-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext18-22+.PHONY: help23 help:24 @echo "Please use \`make <target>' where <target> is one of"25 @echo " html to make standalone HTML files"26 @echo " dirhtml to make HTML files named index.html in directories"1 unmodified line28 @echo " pickle to make pickle files"29 @echo " json to make JSON files"30 @echo " htmlhelp to make HTML files and a HTML help project"31 @echo " qthelp to make HTML files and a qthelp project"32+ @echo " applehelp to make an Apple Help Book"33 @echo " devhelp to make HTML files and a Devhelp project"34 @echo " epub to make an epub"35 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"36 @echo " latexpdf to make LaTeX files and run them through pdflatex"37+ @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"38 @echo " text to make text files"39 @echo " man to make manual pages"40 @echo " texinfo to make Texinfo files"41 @echo " info to make Texinfo files and run them through makeinfo"42 @echo " gettext to make PO message catalogs"43 @echo " changes to make an overview of all changed/added/deprecated items"44+ @echo " xml to make Docutils-native XML files"45+ @echo " pseudoxml to make pseudoxml-XML files for display purposes"46 @echo " linkcheck to check all external links for integrity"47 @echo " doctest to run all doctests embedded in the documentation (if enabled)"48+ @echo " coverage to run coverage check of the documentation (if enabled)"49 50+.PHONY: clean51 clean:42- -rm -rf $(BUILDDIR)/*52+ rm -rf $(BUILDDIR)/*53 54+.PHONY: html55 html:56 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html57 @echo58 @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."59 60+.PHONY: dirhtml61 dirhtml:62 $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml63 @echo64 @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."65 66+.PHONY: singlehtml67 singlehtml:68 $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml69 @echo70 @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."71 72+.PHONY: pickle73 pickle:74 $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle75 @echo76 @echo "Build finished; now you can process the pickle files."77 78+.PHONY: json79 json:80 $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json81 @echo82 @echo "Build finished; now you can process the JSON files."83 84+.PHONY: htmlhelp85 htmlhelp:86 $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp87 @echo88 @echo "Build finished; now you can run HTML Help Workshop with the" \89 ".hhp project file in $(BUILDDIR)/htmlhelp."90 91+.PHONY: qthelp92 qthelp:93 $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp94 @echo95 @echo "Build finished; now you can run "qcollectiongenerator" with the" \1 unmodified line97 @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Requests.qhcp"98 @echo "To view the help file:"99 @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Requests.qhc"100 101+.PHONY: applehelp102+applehelp:103+ $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp104+ @echo105+ @echo "Build finished. The help book is in $(BUILDDIR)/applehelp."106+ @echo "N.B. You won't be able to view it unless you put it in" \107+ "~/Library/Documentation/Help or install it in your application" \108+ "bundle."109+110+.PHONY: devhelp111 devhelp:112 $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp113 @echo114 @echo "Build finished."1 unmodified line116 @echo "# mkdir -p $$HOME/.local/share/devhelp/Requests"117 @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Requests"118 @echo "# devhelp"119 120+.PHONY: epub121 epub:122 $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub123 @echo124 @echo "Build finished. The epub file is in $(BUILDDIR)/epub."125 126+.PHONY: latex127 latex:128 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex129 @echo130 @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."131 @echo "Run \`make' in that directory to run these through (pdf)latex" \132 "(use \`make latexpdf' here to do that automatically)."133 134+.PHONY: latexpdf135 latexpdf:136 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex137 @echo "Running LaTeX files through pdflatex..."108- make -C $(BUILDDIR)/latex all-pdf138+ $(MAKE) -C $(BUILDDIR)/latex all-pdf139 @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."140 141+.PHONY: latexpdfja142+latexpdfja:143+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex144+ @echo "Running LaTeX files through platex and dvipdfmx..."145+ $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja146+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."147+148+.PHONY: text149 text:150 $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text151 @echo152 @echo "Build finished. The text files are in $(BUILDDIR)/text."153 154+.PHONY: man155 man:156 $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man157 @echo158 @echo "Build finished. The manual pages are in $(BUILDDIR)/man."159 160+.PHONY: texinfo161 texinfo:162 $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo163 @echo164 @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."165 @echo "Run \`make' in that directory to run these through makeinfo" \166 "(use \`make info' here to do that automatically)."167 168+.PHONY: info169 info:170 $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo171 @echo "Running Texinfo files through makeinfo..."172 make -C $(BUILDDIR)/texinfo info173 @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."174 175+.PHONY: gettext176 gettext:177 $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale178 @echo179 @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."180 181+.PHONY: changes182 changes:183 $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes184 @echo185 @echo "The overview file is in $(BUILDDIR)/changes."186 187+.PHONY: linkcheck188 linkcheck:189 $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck190 @echo191 @echo "Link check complete; look for any errors in the above output " \192 "or in $(BUILDDIR)/linkcheck/output.txt."193 194+.PHONY: doctest195 doctest:196 $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest197 @echo "Testing of doctests in the sources finished, look at the " \198 "results in $(BUILDDIR)/doctest/output.txt."199+200+.PHONY: coverage201+coverage:202+ $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage203+ @echo "Testing of coverage in the sources finished, look at the " \204+ "results in $(BUILDDIR)/coverage/python.txt."205+206+.PHONY: xml207+xml:208+ $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml209+ @echo210+ @echo "Build finished. The XML files are in $(BUILDDIR)/xml."211+212+.PHONY: pseudoxml213+pseudoxml:214+ $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml215+ @echo216+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."deleted:docs/MANIFEST.in-1 removed
1-include HISTORY.rst README.rst LICENSEdeleted:docs/requirements.txt-2 removed
1-alabaster==0.7.32-Sphinx==1.1.3modified:requests/__init__.py+2 added-2 removed
44 unmodified lines45 __version__ = '2.9.1'46 __build__ = 0x02090147 __author__ = 'Kenneth Reitz'48 __license__ = 'Apache 2.0'49-__copyright__ = 'Copyright 2015 Kenneth Reitz'49+__copyright__ = 'Copyright 2016 Kenneth Reitz'50 51 # Attempt to enable urllib3's SNI support, if possible52 try:53 from .packages.urllib3.contrib import pyopenssl8 unmodified lines62 from .status_codes import codes63 from .exceptions import (64 RequestException, Timeout, URLRequired,65 TooManyRedirects, HTTPError, ConnectionError,66- FileModeWarning,66+ FileModeWarning, ConnectTimeout, ReadTimeout67 )68 69 # Set default logging handler to avoid "No handler found" warnings.70 import logging13 unmodified linesmodified:requests/cookies.py+6 added
275 unmodified lines276 or cookie.path == path):277 dictionary[cookie.name] = cookie.value278 return dictionary279 280+ def __contains__(self, name):281+ try:282+ return super(RequestsCookieJar, self).__contains__(name)283+ except CookieConflictError:284+ return True285+286 def __getitem__(self, name):287 """Dict-like __getitem__() for compatibility with client code. Throws288 exception if there are more than one cookie with name. In that case,289 use the more explicit get() method instead.204 unmodified linesmodified:requests/utils.py+8 added-1 removed
79 unmodified lines80 FileModeWarning81 )82 83 if hasattr(o, 'tell'):84+ try:84- current_position = o.tell()85+ current_position = o.tell()86+ except (OSError, IOError):87+ # This can happen in some weird situations, such as when the file88+ # is actually a special file descriptor like stdin. In this89+ # instance, we don't know what the length is, so set it to zero and90+ # let requests chunk it instead.91+ current_position = total_length92 93 return max(0, total_length - current_position)94 95 630 unmodified linesmodified:tests/test_requests.py+32 added
752 unmodified lines753 assert items == list(items)754 # make sure one can use items multiple times755 assert list(items) == list(items)756 757+ def test_cookie_duplicate_names_different_domains(self):758+ key = 'some_cookie'759+ value = 'some_value'760+ domain1 = 'test1.com'761+ domain2 = 'test2.com'762+763+ jar = requests.cookies.RequestsCookieJar()764+ jar.set(key, value, domain=domain1)765+ jar.set(key, value, domain=domain2)766+ assert key in jar767+ items = jar.items()768+ assert len(items) == 2769+770+ # Verify that CookieConflictError is raised if domain is not specified771+ with pytest.raises(requests.cookies.CookieConflictError):772+ jar.get(key)773+774+ # Verify that CookieConflictError is not raised if domain is specified775+ cookie = jar.get(key, domain=domain1)776+ assert cookie == value777+778+ def test_cookie_duplicate_names_raises_cookie_conflict_error(self):779+ key = 'some_cookie'780+ value = 'some_value'781+ path = 'some_path'782+783+ jar = requests.cookies.RequestsCookieJar()784+ jar.set(key, value, path=path)785+ jar.set(key, value)786+ with pytest.raises(requests.cookies.CookieConflictError):787+ jar.get(key)788+789 def test_time_elapsed_blank(self, httpbin):790 r = requests.get(httpbin('get'))791 td = r.elapsed792 total_seconds = ((td.microseconds + (td.seconds + td.days * 24 * 3600)694 unmodified linesmodified:tests/test_utils.py+14 added
36 unmodified lines37 s = StringIO.StringIO()38 s.write('foobarbogus')39 assert super_len(s) == 040 41+ @pytest.mark.parametrize('error', [IOError, OSError])42+ def test_super_len_handles_files_raising_weird_errors_in_tell(self, error):43+ """44+ If tell() raises errors, assume the cursor is at position zero.45+ """46+ class BoomFile(object):47+ def __len__(self):48+ return 549+50+ def tell(self):51+ raise error()52+53+ assert super_len(BoomFile()) == 054+55 def test_string(self):56 assert super_len('Test') == 457 58 @pytest.mark.parametrize(371 unmodified linesmodified:HISTORY.rst+2 added
7 unmodified lines8 9 **Bugfixes**10 11 - Don't use redirect_cache if allow_redirects=False12+- When passed objects that throw exceptions from ``tell()``, send them via13+ chunked transfer encoding instead of failing.14 15 2.9.1 (2015-12-21)16 ++++++++++++++++++17 1122 unmodified linesmodified:Makefile+2 added-1 removed
26 unmodified lines27 28 publish:29 python setup.py register30 python setup.py sdist upload31- python setup.py bdist_wheel upload31+ python setup.py bdist_wheel --universal upload 32+ rm -fr build dist .egg requests.egg-info33 34 35 docs-init:36 pip install -r docs/requirements.txt4 unmodified linesmodified:README.rst+1 added
72 unmodified lines73 74 .. code-block:: bash75 76 $ pip install requests77+ ✨🍰✨78 79 Satisfaction, guaranteed.80 81 Documentation16 unmodified linesadded:requirements-to-freeze.txt+4 added
1+pytest2+pytest-cov3+pytest-httpbin4+sphinxmodified:requirements.txt+22 added-6 removed
1-py==1.4.302-pytest==2.8.13-pytest-cov==2.1.04-pytest-httpbin==0.0.75-httpbin==0.4.06-wheel1+alabaster==0.7.72+Babel==2.2.03+coverage==4.0.34+decorator==4.0.95+docutils==0.126+Flask==0.10.17+httpbin==0.4.18+itsdangerous==0.249+Jinja2==2.810+MarkupSafe==0.2311+py==1.4.3112+Pygments==2.1.113+pytest==2.8.714+pytest-cov==2.2.115+pytest-httpbin==0.2.016+pytz==2015.717+six==1.10.018+snowballstemmer==1.2.119+Sphinx==1.3.520+sphinx-rtd-theme==0.1.921+Werkzeug==0.11.422+wheel==0.29.0deleted:setup.cfg-2 removed
1-[wheel]2-universal = 1