Skip to content
Myr

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

27 files+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 */1213var 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 }108109 typeof callback === "string" && konami.load(callback);110 if (typeof callback === "function") {111 konami.code = callback;112 konami.load();113 }114115 return konami;116};
added:docs/_templates/hacks.html+54 added
deleted:docs/_templates/layout.html-86 removed
1{%- extends "basic/layout.html" %}2{%- block extrahead %}34 {{ super() }}56 {% if theme_touch_icon %}7 <link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />8 {% endif %}910 <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">1112 <style type="text/css">13 img.logo {margin-left: -20px!important;}14 </style>1516{% endblock %}17{%- block relbar2 %}{% endblock %}18{%- block footer %}19 <div class="footer">20 &copy; 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>2526 <script type="text/javascript" src="https://gumroad.com/js/gumroad.js"></script>2728 <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>454647 <script type="text/javascript">4849 var _gaq = _gaq || [];50 _gaq.push(['_setAccount', 'UA-8742933-11']);51 _gaq.push(['_setDomainName', 'none']);52 _gaq.push(['_setAllowLinker', true]);53 _gaq.push(['_trackPageview']);5455 (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 })();6061 </script>6263 <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>7677 <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
modified:docs/_templates/sidebarlogo.html+33 added-6 removed
modified:docs/dev/contributing.rst+94 added-33 removed
1 unmodified line
23Contributor's Guide4===================56If you're reading this you're probably interested in contributing to7Requests. First, We'd like to say: thank you! Open source projects8live-and-die based on the support they receive from others, and the fact that9you're even considering supporting Requests is very generous of10you.6If you're reading this, you're probably interested in contributing to Requests.7Thank you very much! Open source projects live-and-die based on the support8they receive from others, and the fact that you're even considering9contributing to the Requests project is *very* generous of you.1012This document lays out guidelines and advice for contributing to Requests.13If you're thinking of contributing, start by reading this thoroughly and14getting a feel for how contributing to the project works. If you have any11This document lays out guidelines and advice for contributing to this project.12If you're thinking of contributing, please start by reading this document and13getting 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.1618The guide is split into sections based on the type of contribution you're19thinking of making, with a section that covers general guidelines for all20contributors.2117.. _Ian Cordasco: http://www.coglib.com/~icordasc/18.. _Cory Benfield: https://lukasa.co.uk/about1920If you have non-technical feedback, philosophical ponderings, crazy ideas, or21other general thoughts about Requests or its position within the Python22ecosystem, the BDFL, `Kenneth Reitz`_, would love to hear from you.2326All Contributions27-----------------24The guide is split into sections based on the type of contribution you're25thinking of making, with a section that covers general guidelines for all26contributors.2728.. _Kenneth Reitz: mailto:me@kennethreitz.org2930Be Cordial30~~~~~~~~~~31----------3232**Be cordial or be on your way.**33 **Be cordial or be on your way**. *—Kenneth Reitz*3435Requests has one very important rule governing all forms of contribution,36including reporting bugs or requesting features. This golden rule is37"`be cordial or be on your way`_".3836`be cordial or be on your way`_. **All contributions are welcome**, as long as39**All contributions are welcome**, as long as40everyone involved is treated with respect.4142.. _be cordial or be on your way: http://kennethreitz.org/be-cordial-or-be-on-your-way/4344.. _early-feedback:4546Get Early Feedback44~~~~~~~~~~~~~~~~~~47------------------4849If you are contributing, do not feel the need to sit on your contribution until50it is perfectly polished and complete. It helps everyone involved for you to51seek feedback as early as you possibly can. Submitting an early, unfinished
1 unmodified line
53getting that contribution accepted, and can save you from putting a lot of work54into a contribution that is not suitable for the project.5556Contribution Suitability54~~~~~~~~~~~~~~~~~~~~~~~~57------------------------5856The project maintainer has the last word on whether or not a contribution is57suitable for Requests. All contributions will be considered, but from time58to time contributions will be rejected because they do not suit the project.59Our project maintainers have the last word on whether or not a contribution is60suitable for Requests. All contributions will be considered carefully, but from61time to time, contributions will be rejected because they do not suit the62current goals or needs of the project.6360If your contribution is rejected, don't despair! So long as you followed these61guidelines, you'll have a much better chance of getting your next contribution62accepted.64If your contribution is rejected, don't despair! As long as you followed these65guidelines, you will have a much better chance of getting your next66contribution accepted.676869Code Contributions70------------------7168Steps69~~~~~72Steps for Submitting Code73~~~~~~~~~~~~~~~~~~~~~~~~~7475When contributing code, you'll want to follow this checklist:76771. Fork the repository on GitHub.
29 unmodified lines
107asking for help.108109Please also check the :ref:`early-feedback` section.110111Kenneth Reitz's Code Style™112~~~~~~~~~~~~~~~~~~~~~~~~~~~113114The Requests codebase uses the `PEP 8`_ code style.115116In addition to the standards outlined in PEP 8, we have a few guidelines:117118- 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.121122Additionally, one of the styles that PEP8 recommends for `line continuations`_123completely lacks all sense of taste, and is not to be permitted within124the Requests codebase::125126 # Aligned with opening delimiter.127 foo = long_function_name(var_one, var_two,128 var_three, var_four)129130No. Just don't. Please.131132Docstrings are to follow the following syntaxes::133134 def the_earth_is_flat():135 """NASA divided up the seas into thirty-three degrees."""136 pass137138::139140 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.148149 Spiral out. Keep going...150 """151 pass152153All functions, methods, and classes are to contain docstrings. Object data154model methods (e.g. ``__repr__``) are typically the exception to this rule.155156Thanks for helping to make the world a better place!157158.. _PEP 8: http://pep8.org159.. _line continuations: https://www.python.org/dev/peps/pep-0008/#indentation160161Documentation Contributions162---------------------------163164Documentation improvements are always welcome! The documentation files live in165the ``docs/`` directory of the codebase. They're written in166`reStructuredText`_, and use `Sphinx`_ to generate the full suite of167documentation.168115When contributing documentation, please attempt to follow the style of the169When contributing documentation, please do your best to follow the style of the170documentation files. This means a soft-limit of 79 characters wide in your text117files and a semi-formal prose style.171files and a semi-formal, yet friendly and approachable, prose style.172173When presenting Python code, use single-quoted strings (``'hello'`` instead of174``"hello"``).175176.. _reStructuredText: http://docutils.sourceforge.net/rst.html177.. _Sphinx: http://sphinx-doc.org/index.html178179
12 unmodified lines
192193Feature Requests194----------------195139Requests is in a perpetual feature freeze. The maintainers believe that140requests contains every major feature currently required by the vast majority141of users.196Requests is in a perpetual feature freeze, only the BDFL can add or approve of197new features. The maintainers believe that Requests is a feature-complete198piece of software at this time.199200One of the most important skills to have while maintaining a largely-used201open source project is learning the ability to say "no" to suggested changes,202while keeping an open ear and mind.203204If you believe there is a feature missing, feel free to raise a feature205request, but please do be aware that the overwhelming likelihood is that your145feature request will not be accepted.206feature request will not be accepted.
modified:docs/user/advanced.rst+42 added-27 removed
22 unmodified lines
2324 s = requests.Session()2526 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')2829 print(r.text)30 # '{"cookies": {"sessioncookie": "123456789"}}'31
17 unmodified lines
49requests, even if using a session. This example will only send the cookies50with the first request, but not the second::5152 s = requests.Session()5354 r = s.get('http://httpbin.org/cookies', cookies={'from-my': 'browser'})55 print(r.text)56 # '{"cookies": {"from-my": "browser"}}'57
71 unmodified lines
129130 from requests import Request, Session131132 s = Session()132 req = Request('GET', url,133 data=data,134 headers=header135 )133134 req = Request('POST', url, data=data, headers=headers)135 prepped = req.prepare()136137 # do something with prepped.body138 prepped.body = 'No, I want exactly this as the body.'139140 # do something with prepped.headers141 del prepped.headers['Content-Type']142143 resp = s.send(prepped,144 stream=stream,145 verify=verify,
20 unmodified lines
166167 from requests import Request, Session168169 s = Session()168 req = Request('GET', url,169 data=data170 headers=headers171 )170 req = Request('GET', url, data=data, headers=headers)171172 prepped = s.prepare_request(req)173174 # do something with prepped.body175 prepped.body = 'Seriously, send exactly these bytes.'176177 # do something with prepped.headers178 prepped.headers['Keep-Dead'] = 'parrot'179180 resp = s.send(prepped,181 stream=stream,182 verify=verify,
174 unmodified lines
357POST Multiple Multipart-Encoded Files358-------------------------------------359360You can send multiple files in one request. For example, suppose you want to359upload image files to an HTML form with a multiple file field 'images':361upload image files to an HTML form with a multiple file field 'images'::362363 <input type="file" name="images" multiple="true" required="true"/>364363To do that, just set files to a list of tuples of (form_field_name, file_info):365To do that, just set files to a list of tuples of ``(form_field_name, file_info)``::366367 >>> 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 lines
493 the resulting iterator object instead::494495 lines = r.iter_lines()496 # Save the first line for later or just skip it497498 first_line = next(lines)499500 for line in lines:501 print(line)502503.. _proxies:
6 unmodified lines
510511 import requests512513 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 }517513 requests.get("http://example.org", proxies=proxies)518 requests.get('http://example.org', proxies=proxies)519520You can also configure proxies by setting the environment variables521``HTTP_PROXY`` and ``HTTPS_PROXY``.522523::524525 $ export HTTP_PROXY="http://10.10.1.10:3128"526 $ export HTTPS_PROXY="http://10.10.1.10:1080"527528 $ python529 >>> import requests524 >>> requests.get("http://example.org")530 >>> requests.get('http://example.org')531532To use HTTP Basic Auth with your proxy, use the `http://user:password@host/` syntax::533528 proxies = {529 "http": "http://user:pass@10.10.1.10:3128/",530 }534 proxies = {'http': 'http://user:pass@10.10.1.10:3128/'}535536To give a proxy for a specific scheme and host, use the537`scheme://hostname` form for the key. This will match for538any request to the given scheme and exact hostname.539540::541538 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'}543544Note that proxy URLs must include the scheme.545546.. _compliance:
56 unmodified lines
603604::605606 >>> commit_data = r.json()607608 >>> print(commit_data.keys())609 [u'committer', u'author', u'url', u'tree', u'sha', u'parents', u'message']610611 >>> 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'}613614 >>> print(commit_data[u'message'])615 makin' history616617So far, so simple. Well, let's investigate the GitHub API a little bit. Now,
31 unmodified lines
649650 >>> r = requests.get('https://api.github.com/repos/kennethreitz/requests/issues/482')651 >>> r.status_code652 200653654 >>> issue = json.loads(r.text)655656 >>> print(issue[u'title'])657 Feature any http verb in docs658659 >>> print(issue[u'comments'])660 3661662Cool, we have three comments. Let's take a look at the last of them.
2 unmodified lines
665666 >>> r = requests.get(r.url + u'/comments')667 >>> r.status_code668 200669670 >>> comments = r.json()671672 >>> print(comments[0].keys())673 [u'body', u'url', u'created_at', u'updated_at', u'user', u'id']674675 >>> print(comments[2][u'body'])676 Probably in the "advanced" section677678Well, that seems like a silly place. Let's post a comment telling the poster
11 unmodified lines
690::691692 >>> 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"694695 >>> r = requests.post(url=url, data=body)696 >>> r.status_code697 404698
4 unmodified lines
703::704705 >>> from requests.auth import HTTPBasicAuth706 >>> auth = HTTPBasicAuth('fake@example.com', 'not_a_real_password')707708 >>> r = requests.post(url=url, data=body, auth=auth)709 >>> r.status_code710 201711712 >>> content = r.json()713 >>> print(content[u'body'])714 Sounds great! I'll get right on it.715
5 unmodified lines
721::722723 >>> print(content[u"id"])724 5804413725726 >>> 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"728729 >>> r = requests.patch(url=url, data=body, auth=auth)730 >>> r.status_code731 200732
112 unmodified lines
845 class Ssl3HttpAdapter(HTTPAdapter):846 """"Transport adapter" that allows us to use SSLv3."""847848 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)852853.. _`described here`: http://www.kennethreitz.org/essays/the-future-of-python-http854.. _`urllib3`: https://github.com/shazow/urllib3855
58 unmodified lines
modified:docs/user/install.rst+12 added-20 removed
5 unmodified lines
6This part of the documentation covers the installation of Requests.7The first step to using any software package is getting it properly installed.8910Distribute & Pip11----------------10Pip Install Requests11--------------------1213Installing Requests is simple with `pip <https://pip.pypa.io>`_, just run14this in your terminal::13To install Requests, simply run this simple command in your terminal of choice::1415 $ pip install requests1618or, with `easy_install <http://pypi.python.org/pypi/setuptools>`_::17If 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/>`_19can guide you through the process.2020 $ easy_install requests21Get the Source Code22-------------------2322But, you really `shouldn't do that <https://stackoverflow.com/questions/3220404/why-use-pip-over-easy-install>`_.232425Get the Code26------------2724Requests is actively developed on GitHub, where the code is25`always available <https://github.com/kennethreitz/requests>`_.2627You can either clone the public repository::2829 $ git clone git://github.com/kennethreitz/requests.git3035Download the `tarball <https://github.com/kennethreitz/requests/tarball/master>`_::31Or, download the `tarball <https://github.com/kennethreitz/requests/tarball/master>`_::3233 $ curl -OL https://github.com/kennethreitz/requests/tarball/master34 # optionally, zipball is also available (for Windows users).3539Or, download the `zipball <https://github.com/kennethreitz/requests/zipball/master>`_::36Once you have a copy of the source, you can embed it in your own Python37package, or install it into your site-packages easily::3841 $ curl -OL https://github.com/kennethreitz/requests/zipball/master424344Once you have a copy of the source, you can embed it in your Python package,45or install it into your site-packages easily::4639 $ python setup.py install
modified:docs/user/quickstart.rst+22 added-8 removed
35 unmodified lines
3637Requests' simple API means that all forms of HTTP request are as obvious. For38example, this is how you make an HTTP POST request::3940 >>> r = requests.post("http://httpbin.org/post", data = {"key":"value"})40 >>> r = requests.post('http://httpbin.org/post', data = {'key':'value'})4142Nice, right? What about the other HTTP request types: PUT, DELETE, HEAD and43OPTIONS? These are all just as simple::4445 >>> 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')4950That's all well and good, but it's also only the start of what Requests can51do.52
9 unmodified lines
62``key1=value1`` and ``key2=value2`` to ``httpbin.org/get``, you would use the63following code::6465 >>> 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)6768You can see that the URL has been correctly encoded by printing the URL::6970 >>> print(r.url)
4 unmodified lines
7576You can also pass a list of items as a value::7778 >>> payload = {'key1': 'value1', 'key2': ['value2', 'value3']}7979 >>> 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=value38384Response Content
2 unmodified lines
87We can read the content of the server's response. Consider the GitHub timeline88again::8990 >>> import requests9192 >>> r = requests.get('https://api.github.com/events')93 >>> r.text94 u'[{"repository":{"open_issues":0,"url":"https://github.com/...95
36 unmodified lines
132use the following code::133134 >>> from PIL import Image135 >>> from StringIO import StringIO136137 >>> i = Image.open(StringIO(r.content))138139140JSON Response Content
1 unmodified line
142143There's also a builtin JSON decoder, in case you're dealing with JSON data::144145 >>> import requests146147 >>> 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 lines
166server, 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::168169 >>> r = requests.get('https://api.github.com/events', stream=True)170171 >>> r.raw172 <requests.packages.urllib3.response.HTTPResponse object at 0x101194810>173174 >>> r.raw.read(10)175 '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03'176177In general, however, you should use a pattern like this to save what is being
16 unmodified lines
194``headers`` parameter.195196For example, we didn't specify our user-agent in the previous example::197192 >>> import json198 >>> url = 'https://api.github.com/some/endpoint'199 >>> headers = {'user-agent': 'my-app/0.0.1'}200201 >>> r = requests.get(url, headers=headers)
17 unmodified lines
219To do this, simply pass a dictionary to the ``data`` argument. Your220dictionary of data will automatically be form-encoded when the request is made::221222 >>> payload = {'key1': 'value1', 'key2': 'value2'}223224 >>> r = requests.post("http://httpbin.org/post", data=payload)225 >>> print(r.text)226 {227 ...
9 unmodified lines
237238For example, the GitHub API v3 accepts JSON-Encoded POST/PATCH data::239240 >>> import json241242 >>> url = 'https://api.github.com/some/endpoint'243 >>> payload = {'some': 'data'}244245 >>> r = requests.post(url, data=json.dumps(payload))
186 unmodified lines
432433For example, GitHub redirects all HTTP requests to HTTPS::434435 >>> r = requests.get('http://github.com')436437 >>> r.url438 'https://github.com/'439440 >>> r.status_code441 200442443 >>> r.history444 [<Response [301]>]445446447If you're using GET, OPTIONS, POST, PUT, PATCH or DELETE, you can disable448redirection handling with the ``allow_redirects`` parameter::449450 >>> r = requests.get('http://github.com', allow_redirects=False)451452 >>> r.status_code453 301454455 >>> r.history456 []457458If you're using HEAD, you can enable redirection as well::459460 >>> r = requests.head('http://github.com', allow_redirects=True)461462 >>> r.url463 'https://github.com/'464465 >>> r.history466 [<Response [301]>]467468
41 unmodified lines
modified:docs/api.rst+42 added-49 removed
23 unmodified lines
24.. autofunction:: put25.. autofunction:: patch26.. autofunction:: delete2728Exceptions29----------3031.. autoexception:: requests.RequestException32.. autoexception:: requests.ConnectionError33.. autoexception:: requests.HTTPError34.. autoexception:: requests.URLRequired35.. autoexception:: requests.TooManyRedirects36.. autoexception:: requests.ConnectTimeout37.. autoexception:: requests.ReadTimeout38.. autoexception:: requests.Timeout394041Request Sessions42----------------4344.. _sessionapi:4546.. autoclass:: Session47 :inherited-members:484950Lower-Level Classes30~~~~~~~~~~~~~~~~~~~51-------------------5253.. autoclass:: requests.Request54 :inherited-members:5556.. autoclass:: Response57 :inherited-members:5838Request Sessions39----------------5941.. autoclass:: Session60Lower-Lower-Level Classes61-------------------------6263.. autoclass:: requests.PreparedRequest64 :inherited-members:6566.. autoclass:: requests.adapters.HTTPAdapter67 :inherited-members:
5 unmodified lines
73.. autoclass:: requests.auth.HTTPBasicAuth74.. autoclass:: requests.auth.HTTPProxyAuth75.. autoclass:: requests.auth.HTTPDigestAuth7655Exceptions56~~~~~~~~~~7758.. 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.Timeout7879Encodings80---------8168Status Code Lookup69~~~~~~~~~~~~~~~~~~82.. autofunction:: requests.utils.get_encodings_from_content83.. autofunction:: requests.utils.get_encoding_from_headers84.. autofunction:: requests.utils.get_unicode_from_response8571.. autofunction:: requests.codes8673::7475 >>> requests.codes['temporary_redirect']76 3077778 >>> requests.codes.teapot79 4188081 >>> requests.codes['\o/']82 2008387.. _api-cookies:8889Cookies87~~~~~~~90-------9192.. autofunction:: requests.utils.dict_from_cookiejar93.. autofunction:: requests.utils.cookiejar_from_dict94.. autofunction:: requests.utils.add_dict_to_cookiejar
4 unmodified lines
99.. autoclass:: requests.cookies.CookieConflictError100 :inherited-members:101102100Encodings101~~~~~~~~~103103.. autofunction:: requests.utils.get_encodings_from_content104.. autofunction:: requests.utils.get_encoding_from_headers105.. autofunction:: requests.utils.get_unicode_from_response104Status Code Lookup105------------------106107.. autoclass:: requests.codes108108Classes109~~~~~~~109::110111.. autoclass:: requests.Response112 :inherited-members:111 >>> requests.codes['temporary_redirect']112 307113114.. autoclass:: requests.Request115 :inherited-members:114 >>> requests.codes.teapot115 418116117.. autoclass:: requests.PreparedRequest118 :inherited-members:117 >>> requests.codes['\o/']118 200119120.. _sessionapi:120122.. autoclass:: requests.Session123 :inherited-members:121125.. autoclass:: requests.adapters.HTTPAdapter126 :inherited-members:127128122Migrating to 1.x123----------------124125This section details the main differences between 0.x and 1.x and is meant
138 unmodified lines
modified: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.1414import sys, os15import sys16import os1718# 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('.'))2223# Insert Requests' path into the system.24sys.path.insert(0, os.path.abspath('..'))25sys.path.insert(0, os.path.abspath('_themes'))2627import requests28from requests import __version__2923import alabaster3025# -- General configuration -----------------------------------------------------31# -- General configuration ------------------------------------------------3233# If your documentation needs a minimal Sphinx version, state it here.34#needs_sphinx = '1.0'3530# 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.39extensions = [40 'sphinx.ext.autodoc',41 'sphinx.ext.intersphinx',35 'alabaster'42 'sphinx.ext.todo',43 'sphinx.ext.viewcode',44]4546# Add any paths that contain templates here, relative to this directory.47templates_path = ['_templates']4841# 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']52source_suffix = '.rst'5354# The encoding of source files.55#source_encoding = 'utf-8-sig'
3 unmodified lines
5960# General information about the project.61project = u'Requests'62copyright = u'2016. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project'63author = u'Kenneth Reitz'6465# 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.70version = __version__71# The full version, including alpha/beta/rc tags.61release = version72release = __version__7374# 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 = None79language = None8081# There are two options for replacing |today|: either, you set today to some82# non-false value, then it is used:83#today = ''
3 unmodified lines
87# List of patterns, relative to source directory, that match files and88# directories to ignore when looking for source files.89exclude_patterns = ['_build']9077# 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 = None9495# If true, '()' will be appended to :func: etc. cross-reference text.81#add_function_parentheses = True96add_function_parentheses = False9798# If true, the current module name will be prepended to all description99# unit titles (such as .. function::).85#add_module_names = True100add_module_names = True101102# If true, sectionauthor and moduleauthor directives will be shown in the103# output. They are ignored by default.104#show_authors = False
3 unmodified lines
108109# A list of ignored prefixes for module index sorting.110#modindex_common_prefix = []111112# If true, keep warnings as "system message" paragraphs in the built documents.113#keep_warnings = False11498# -- Options for HTML output ---------------------------------------------------115# If true, `todo` and `todoList` produce output, else they produce nothing.116todo_include_todos = True117118119# -- Options for HTML output ----------------------------------------------120121# The theme to use for HTML and HTML Help pages. See the documentation for122# a list of builtin themes.102html_theme = 'default'123html_theme = 'alabaster'124125# 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.128html_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}135136# Add any paths that contain custom themes here, relative to this directory.137#html_theme_path = []
8 unmodified lines
146# The name of an image file (relative to this directory) to place at the top147# of the sidebar.148#html_logo = None149128150# 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 = None
2 unmodified lines
156# 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".158html_static_path = ['_static']159160# 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 = []164165# 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'168169# If true, SmartyPants will be used to convert quotes and dashes to170# typographically correct entities.145#html_use_smartypants = True171html_use_smartypants = False172173# Custom sidebar templates, maps document names to template names.174html_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}180181# Additional templates that should be rendered to pages, maps page names to182# template names.
14 unmodified lines
197# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.198html_show_sphinx = False199200# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.174#html_show_copyright = True201html_show_copyright = True202203# 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 line
207208# This is the file name suffix for HTML files (e.g. ".xhtml").209#html_file_suffix = None210211# 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'216217# 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'}220221# 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'224225# Output file base name for HTML help builder.226htmlhelp_basename = 'Requestsdoc'227228# -- Options for LaTeX output ---------------------------------------------229188# -- Options for LaTeX output --------------------------------------------------230latex_elements = {231# The paper size ('letterpaper' or 'a4paper').232#'papersize': 'letterpaper',233190# The paper size ('letter' or 'a4').191#latex_paper_size = 'letter'192234# The font size ('10pt', '11pt' or '12pt').194#latex_font_size = '10pt'235#'pointsize': '10pt',236237# Additional stuff for the LaTeX preamble.238#'preamble': '',239240# Latex figure (float) alignment241#'figure_align': 'htbp',242}243244# 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]).247latex_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]251252# The name of an image file (relative to this directory) to place at the top of253# the title page.
8 unmodified lines
262263# If true, show URL addresses after external links.264#latex_show_urls = False265217# Additional stuff for the LaTeX preamble.218#latex_preamble = ''219266# Documents to append as an appendix to all manuals.267#latex_appendices = []268269# If false, no module index is generated.270#latex_domain_indices = True271272227# -- Options for manual page output --------------------------------------------273# -- Options for manual page output ---------------------------------------274275# One entry per manual page. List of tuples276# (source start file, name, description, authors, manual section).277man_pages = [232 ('index', 'requests', u'Requests Documentation',233 [u'Kenneth Reitz'], 1)278 (master_doc, 'requests', u'Requests Documentation',279 [author], 1)280]281282# If true, show URL addresses after external links.283#man_show_urls = False284239# -- Options for Texinfo output ------------------------------------------------285286# -- Options for Texinfo output -------------------------------------------287288# Grouping the document tree into Texinfo files. List of tuples289# (source start file, target name, title, author,290# dir menu entry, description, category)291texinfo_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]296297# Documents to append as an appendix to all manuals.250texinfo_appendices = []298#texinfo_appendices = []299252sys.path.append(os.path.abspath('_themes'))253html_theme_path =[alabaster.get_path()]254html_theme = 'alabaster'300# If false, no module index is generated.301#texinfo_domain_indices = True302303# How to display URL addresses: 'footnote', 'no', or 'inline'.304#texinfo_show_urls = 'footnote'305306# If true, do not generate a @detailmenu in the "Top" node's menu.307#texinfo_no_detailmenu = False308309310# -- Options for Epub output ----------------------------------------------311312# Bibliographic Dublin Core info.313epub_title = project314epub_author = author315epub_publisher = author316epub_copyright = copyright317318# The basename for the epub file. It defaults to the project name.319#epub_basename = project320321# 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'326327# The language of the text. It defaults to the language option328# or 'en' if the language is not set.329#epub_language = ''330331# The scheme of the identifier. Typical schemes are ISBN or URL.332#epub_scheme = ''333334# The unique identifier of the text. This can be a ISBN number335# or the project homepage.336#epub_identifier = ''337338# A unique identification for the text.339#epub_uid = ''340341# A tuple containing the cover image and cover page html template filenames.342#epub_cover = ()343344# A sequence of (type, uri, title) tuples for the guide element of content.opf.345#epub_guide = ()346347# 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 = []350351# 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 = []354355# A list of files that should not be packed into the epub file.356epub_exclude_files = ['search.html']357358# The depth of the table of contents in toc.ncx.359#epub_tocdepth = 3360361# Allow duplicate toc entries.362#epub_tocdup = True363364# Choose between 'default' and 'includehidden'.365#epub_tocscope = 'default'366367# Fix unsupported image types using the Pillow.368#epub_fix_images = False369370# Scale large images.371#epub_max_image_width = 0372373# How to display URL addresses: 'footnote', 'no', or 'inline'.374#epub_show_urls = 'inline'375376# If false, no index is generated.377#epub_use_index = True378379intersphinx_mapping = {'urllib3': ('http://urllib3.readthedocs.org/en/latest', None)}
modified:docs/index.rst+17 added-14 removed
36 unmodified lines
37URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling38are 100% automatic, powered by `urllib3 <https://github.com/shazow/urllib3>`_,39which is embedded within Requests.4041Testimonials42------------41User Testimonials42-----------------4344Her Majesty's Government, Amazon, Google, Twilio, Runscope, Mozilla, Heroku,45PayPal, NPR, Obama for America, Transifex, Native Instruments, The Washington46Post, Twitter, SoundCloud, Kippt, Readability, Sony, and Federal U.S.
17 unmodified lines
6465Requests is one of the most downloaded Python packages of all time, pulling in66over 7,000,000 downloads every month. All the cool kids are doing it!6768Feature Support69---------------68Supported Features69------------------7071Requests is ready for today's web.7273- International Domains and URLs
15 unmodified lines
8990Requests supports Python 2.6 — 3.5, and runs great on PyPy.919293User Guide94----------93The User Guide94--------------9596This part of the documentation, which is mostly prose, begins with some97background information about Requests, then focuses on step-by-step98instructions for getting the most out of Requests.
7 unmodified lines
106 user/advanced107 user/authentication108109110Community Guide111-----------------110The Community Guide111-------------------112113This part of the documentation, which is mostly prose, details the114Requests ecosystem and community.115
7 unmodified lines
123 community/vulnerabilities124 community/updates125 community/release-process126127API Documentation128-----------------127The API Documentation / Guide128-----------------------------129130If you are looking for information on a specific function, class or method,130If you are looking for information on a specific function, class, or method,131this part of the documentation is for you.132133.. toctree::134 :maxdepth: 2135136 api137138139Contributor Guide140-----------------139The Contributor Guide140---------------------141142If you want to contribute to the project, this part of the documentation is for143you.144145.. toctree::146 :maxdepth: 1146 :maxdepth: 3147148 dev/contributing149 dev/philosophy150 dev/todo151 dev/authors152153There are no more guides. You are now guideless.154Good luck.
modified:docs/make.bat+263 added-190 removed
1@ECHO OFF23REM Command file for Sphinx documentation45if "%SPHINXBUILD%" == "" (6 set SPHINXBUILD=sphinx-build7)8set BUILDDIR=_build9set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .10set I18NSPHINXOPTS=%SPHINXOPTS% .11if NOT "%PAPER%" == "" (12 set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%13 set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%14)1516if "%1" == "" goto help1718if "%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)4041if "%1" == "clean" (42 for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i43 del /q /s %BUILDDIR%\*44 goto end45)4647if "%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)5455if "%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)6263if "%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)7071if "%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)7879if "%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)8687if "%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)9596if "%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)107108if "%1" == "devhelp" (109 %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp110 if errorlevel 1 exit /b 1111 echo.112 echo.Build finished.113 goto end114)115116if "%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)123124if "%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)131132if "%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)139140if "%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)147148if "%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)155156if "%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)163164if "%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)171172if "%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 ^177or in %BUILDDIR%/linkcheck/output.txt.178 goto end179)180181if "%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 ^186results in %BUILDDIR%/doctest/output.txt.187 goto end188)189190:end1@ECHO OFF23REM Command file for Sphinx documentation45if "%SPHINXBUILD%" == "" (6 set SPHINXBUILD=sphinx-build7)8set BUILDDIR=_build9set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .10set I18NSPHINXOPTS=%SPHINXOPTS% .11if NOT "%PAPER%" == "" (12 set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%13 set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%14)1516if "%1" == "" goto help1718if "%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)4344if "%1" == "clean" (45 for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i46 del /q /s %BUILDDIR%\*47 goto end48)495051REM Check if sphinx-build is available and fallback to Python version if any52%SPHINXBUILD% 1>NUL 2>NUL53if errorlevel 9009 goto sphinx_python54goto sphinx_ok5556:sphinx_python5758set SPHINXBUILD=python -m sphinx.__init__59%SPHINXBUILD% 2> nul60if 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)7172:sphinx_ok737475if "%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)8283if "%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)9091if "%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)9899if "%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)106107if "%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)114115if "%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)123124if "%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)135136if "%1" == "devhelp" (137 %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp138 if errorlevel 1 exit /b 1139 echo.140 echo.Build finished.141 goto end142)143144if "%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)151152if "%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)159160if "%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)169170if "%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)179180if "%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)187188if "%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)195196if "%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)203204if "%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)211212if "%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)219220if "%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 ^225or in %BUILDDIR%/linkcheck/output.txt.226 goto end227)228229if "%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 ^234results in %BUILDDIR%/doctest/output.txt.235 goto end236)237238if "%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 ^243results in %BUILDDIR%/coverage/python.txt.244 goto end245)246247if "%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)254255if "%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)262263:end
modified:docs/Makefile+67 added-4 removed
5 unmodified lines
6SPHINXBUILD = sphinx-build7PAPER =8BUILDDIR = _build910# User-friendly check for sphinx-build11ifeq ($(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/)13endif1415# Internal variables.16PAPEROPT_a4 = -D latex_paper_size=a417PAPEROPT_letter = -D latex_paper_size=letter18ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .19# the i18n builder cannot share the environment and doctrees with the others20I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .2117.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext1822.PHONY: help23help: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 line
28 @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)"4950.PHONY: clean51clean:42 -rm -rf $(BUILDDIR)/*52 rm -rf $(BUILDDIR)/*5354.PHONY: html55html:56 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html57 @echo58 @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."5960.PHONY: dirhtml61dirhtml:62 $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml63 @echo64 @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."6566.PHONY: singlehtml67singlehtml:68 $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml69 @echo70 @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."7172.PHONY: pickle73pickle:74 $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle75 @echo76 @echo "Build finished; now you can process the pickle files."7778.PHONY: json79json:80 $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json81 @echo82 @echo "Build finished; now you can process the JSON files."8384.PHONY: htmlhelp85htmlhelp: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."9091.PHONY: qthelp92qthelp:93 $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp94 @echo95 @echo "Build finished; now you can run "qcollectiongenerator" with the" \
1 unmodified line
97 @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Requests.qhcp"98 @echo "To view the help file:"99 @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Requests.qhc"100101.PHONY: applehelp102applehelp: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."109110.PHONY: devhelp111devhelp:112 $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp113 @echo114 @echo "Build finished."
1 unmodified line
116 @echo "# mkdir -p $$HOME/.local/share/devhelp/Requests"117 @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Requests"118 @echo "# devhelp"119120.PHONY: epub121epub:122 $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub123 @echo124 @echo "Build finished. The epub file is in $(BUILDDIR)/epub."125126.PHONY: latex127latex: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)."133134.PHONY: latexpdf135latexpdf: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."140141.PHONY: latexpdfja142latexpdfja: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."147148.PHONY: text149text:150 $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text151 @echo152 @echo "Build finished. The text files are in $(BUILDDIR)/text."153154.PHONY: man155man:156 $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man157 @echo158 @echo "Build finished. The manual pages are in $(BUILDDIR)/man."159160.PHONY: texinfo161texinfo: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)."167168.PHONY: info169info: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."174175.PHONY: gettext176gettext:177 $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale178 @echo179 @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."180181.PHONY: changes182changes:183 $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes184 @echo185 @echo "The overview file is in $(BUILDDIR)/changes."186187.PHONY: linkcheck188linkcheck: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."193194.PHONY: doctest195doctest: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."199200.PHONY: coverage201coverage: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."205206.PHONY: xml207xml:208 $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml209 @echo210 @echo "Build finished. The XML files are in $(BUILDDIR)/xml."211212.PHONY: pseudoxml213pseudoxml: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
1include HISTORY.rst README.rst LICENSE
deleted:docs/requirements.txt-2 removed
1alabaster==0.7.32Sphinx==1.1.3
modified:requests/__init__.py+2 added-2 removed
44 unmodified lines
45__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'5051# Attempt to enable urllib3's SNI support, if possible52try:53 from .packages.urllib3.contrib import pyopenssl
8 unmodified lines
62from .status_codes import codes63from .exceptions import (64 RequestException, Timeout, URLRequired,65 TooManyRedirects, HTTPError, ConnectionError,66 FileModeWarning,66 FileModeWarning, ConnectTimeout, ReadTimeout67)6869# Set default logging handler to avoid "No handler found" warnings.70import logging
13 unmodified lines
modified:requests/cookies.py+6 added
275 unmodified lines
276 or cookie.path == path):277 dictionary[cookie.name] = cookie.value278 return dictionary279280 def __contains__(self, name):281 try:282 return super(RequestsCookieJar, self).__contains__(name)283 except CookieConflictError:284 return True285286 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 lines
modified:requests/utils.py+8 added-1 removed
79 unmodified lines
80 FileModeWarning81 )8283 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_length9293 return max(0, total_length - current_position)9495
630 unmodified lines
modified:tests/test_requests.py+32 added
752 unmodified lines
753 assert items == list(items)754 # make sure one can use items multiple times755 assert list(items) == list(items)756757 def test_cookie_duplicate_names_different_domains(self):758 key = 'some_cookie'759 value = 'some_value'760 domain1 = 'test1.com'761 domain2 = 'test2.com'762763 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) == 2769770 # Verify that CookieConflictError is raised if domain is not specified771 with pytest.raises(requests.cookies.CookieConflictError):772 jar.get(key)773774 # Verify that CookieConflictError is not raised if domain is specified775 cookie = jar.get(key, domain=domain1)776 assert cookie == value777778 def test_cookie_duplicate_names_raises_cookie_conflict_error(self):779 key = 'some_cookie'780 value = 'some_value'781 path = 'some_path'782783 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)788789 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 lines
modified:tests/test_utils.py+14 added
36 unmodified lines
37 s = StringIO.StringIO()38 s.write('foobarbogus')39 assert super_len(s) == 04041 @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 54950 def tell(self):51 raise error()5253 assert super_len(BoomFile()) == 05455 def test_string(self):56 assert super_len('Test') == 45758 @pytest.mark.parametrize(
371 unmodified lines
modified:HISTORY.rst+2 added
7 unmodified lines
89**Bugfixes**1011- 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.14152.9.1 (2015-12-21)16++++++++++++++++++17
1122 unmodified lines
modified:Makefile+2 added-1 removed
26 unmodified lines
2728publish: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-info333435docs-init:36 pip install -r docs/requirements.txt
4 unmodified lines
modified:README.rst+1 added
72 unmodified lines
7374.. code-block:: bash7576 $ pip install requests77 ✨🍰✨7879Satisfaction, guaranteed.8081Documentation
16 unmodified lines
added:requirements-to-freeze.txt+4 added
1pytest2pytest-cov3pytest-httpbin4sphinx
modified:requirements.txt+22 added-6 removed
1py==1.4.302pytest==2.8.13pytest-cov==2.1.04pytest-httpbin==0.0.75httpbin==0.4.06wheel1alabaster==0.7.72Babel==2.2.03coverage==4.0.34decorator==4.0.95docutils==0.126Flask==0.10.17httpbin==0.4.18itsdangerous==0.249Jinja2==2.810MarkupSafe==0.2311py==1.4.3112Pygments==2.1.113pytest==2.8.714pytest-cov==2.2.115pytest-httpbin==0.2.016pytz==2015.717six==1.10.018snowballstemmer==1.2.119Sphinx==1.3.520sphinx-rtd-theme==0.1.921Werkzeug==0.11.422wheel==0.29.0
deleted:setup.cfg-2 removed
1[wheel]2universal = 1