Skip to content
Myr

Merge remote-tracking branch 'upstream/develop' into develop

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

authored by Jérémy Bethmont · committed by Jérémy Bethmont · parents 571d808, 9471b0a · Browse files · 10 files+54 added−107 removed
This commit

State

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

Diff stats

10 files+54 added−107 removed

  • other:+54 added−107 removed

10 files+54 added−107 removed

modified:docs/community/faq.rst+1 added-1 removed
32 unmodified lines
3334Python 3 Support?35-----------------3637It's on the way.37It's on the way. Here's a list of `supported interpreters <interpreters>`_.383940Keep-alive Support?41-------------------
2 unmodified lines
modified:docs/user/advanced.rst+1 added
21 unmodified lines
22 s.get('http://httpbin.org/cookies/set/sessioncookie/123456789')23 r = s.get("http://httpbin.org/cookies")2425 print r.content26 # '{"cookies": {"sessioncookie": "123456789"}}'272829Sessions can also be used to provide default data to the request methods::30
107 unmodified lines
modified:docs/user/intro.rst+9 added
1.. _introduction:23Introduction4============56Philosophy
34 unmodified lines
4142 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.434445.. _interpreters:46Python Interpreters47-------------------4849At this time, the following Python platforms are officially supported:5051* cPython 2.552* cPython 2.5.553* cPython 2.5.654* cPython 2.655* cPython 2.6.656* cPython 2.6.757* cPython 2.758* cPython 2.7.159* cPython 2.7.260* PyPy-c 1.461* PyPy-c 1.56263
1 unmodified line
modified:docs/user/quickstart.rst+1 added-1 removed
62 unmodified lines
63 File "requests/models.py", line 394, in raise_for_status64 raise self.error65 urllib2.HTTPError: HTTP Error 404: NOT FOUND6667But, sice our ``status_code`` was ``200``, when we call it::67But, since our ``status_code`` was ``200``, when we call it::6869 >>> r.raise_for_status()70 None71
63 unmodified lines
modified:docs/api.rst+1 added-12 removed
20 unmodified lines
21.. autofunction:: post22.. autofunction:: put23.. autofunction:: patch24.. autofunction:: delete25.. autofunction:: request262627-----------282930.. autoclass:: requests.models.Response
18 unmodified lines
49These items are an internal component to Requests, and should never be50seen by the end user (developer). This part of the API documentation51exists for those who are extending the functionality of Requests.5253Functions54~~~~~~~~~5556.. autofunction:: request5753Classes54~~~~~~~5556.. autoclass:: requests.models.Request57 :inherited-members:6364Structures65~~~~~~~~~~6667.. autoclass:: requests.structures.CaseInsensitiveDict68 :inherited-members:
modified:requests/api.py+8 added-8 removed
31 unmodified lines
32 :param url: URL for the new :class:`Request` object.33 :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.34 :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.35 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.36 :param cookies: (optional) CookieJar object to send with the :class:`Request`.36 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.37 :param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.38 :param auth: (optional) AuthObject to enable Basic HTTP Auth.39 :param timeout: (optional) Float describing the timeout of the request.40 :param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
21 unmodified lines
6263 # Arguments manipulation hook.64 args = dispatch_hook('args', hooks, args)6566 r = Request(hooks=hooks, **args)66 r = Request(**args)6768 # Pre-request hook.69 r = dispatch_hook('pre_request', hooks, r)70
15 unmodified lines
8687 :param url: URL for the new :class:`Request` object.88 :param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.89 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.90 :param cookies: (optional) CookieJar object to send with the :class:`Request`.90 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.91 :param auth: (optional) AuthObject to enable Basic HTTP Auth.92 :param timeout: (optional) Float describing the timeout of the request.93 :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.94 """
7 unmodified lines
102103 :param url: URL for the new :class:`Request` object.104 :param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.105 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.106 :param cookies: (optional) CookieJar object to send with the :class:`Request`.106 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.107 :param auth: (optional) AuthObject to enable Basic HTTP Auth.108 :param timeout: (optional) Float describing the timeout of the request.109 :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.110 """
8 unmodified lines
119 :param url: URL for the new :class:`Request` object.120 :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.121 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.122 :param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.123 :param cookies: (optional) CookieJar object to send with the :class:`Request`.123 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.124 :param auth: (optional) AuthObject to enable Basic HTTP Auth.125 :param timeout: (optional) Float describing the timeout of the request.126 :param allow_redirects: (optional) Boolean. Set to True if redirect following is allowed.127 :param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.
9 unmodified lines
137 :param url: URL for the new :class:`Request` object.138 :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.139 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.140 :param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.141 :param cookies: (optional) CookieJar object to send with the :class:`Request`.141 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.142 :param auth: (optional) AuthObject to enable Basic HTTP Auth.143 :param timeout: (optional) Float describing the timeout of the request.144 :param allow_redirects: (optional) Boolean. Set to True if redirect following is allowed.145 :param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.
9 unmodified lines
155 :param url: URL for the new :class:`Request` object.156 :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.157 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.158 :param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.159 :param cookies: (optional) CookieJar object to send with the :class:`Request`.159 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.160 :param auth: (optional) AuthObject to enable Basic HTTP Auth.161 :param timeout: (optional) Float describing the timeout of the request.162 :param allow_redirects: (optional) Boolean. Set to True if redirect following is allowed.163 :param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.
9 unmodified lines
173174 :param url: URL for the new :class:`Request` object.175 :param params: (optional) Dictionary of parameters, or bytes, to be sent in the query string for the :class:`Request`.176 :param headers: (optional) Dictionary of HTTP Headers to sent with the :class:`Request`.177 :param cookies: (optional) CookieJar object to send with the :class:`Request`.177 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.178 :param auth: (optional) AuthObject to enable Basic HTTP Auth.179 :param timeout: (optional) Float describing the timeout of the request.180 :param allow_redirects: (optional) Boolean. Set to True if redirect following is allowed.181 :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
3 unmodified lines
modified:requests/models.py+2 added-4 removed
35 unmodified lines
3637 def __init__(self,38 url=None, headers=dict(), files=None, method=None, data=dict(),39 params=dict(), auth=None, cookiejar=None, timeout=None, redirect=False,40 allow_redirects=False, proxies=None, hooks=None):40 allow_redirects=False, proxies=None):4142 #: Float describ the timeout of the request.43 # (Use socket.setdefaulttimeout() as fallback)44 self.timeout = timeout
48 unmodified lines
9394 #: True if Request has been sent.95 self.sent = False9697 #: Dictionary of event hook callbacks.98 self.hooks = hooks9710098 # Header manipulation and defaults.99100 if settings.accept_gzip:101 settings.base_headers.update({'Accept-Encoding': 'gzip'})
308 unmodified lines
410 #: up here.411 self.history = []412 #: The Request that created the Response.413 self.request = None414 #: A dictionary of Cookies the server sent back.415 self.cookies = None416417418 def __repr__(self):
207 unmodified lines
modified:AUTHORS+1 added-1 removed
29 unmodified lines
30- 潘旭 (Xu Pan)31- Tamás Gulácsi32- Rubén Abad33- Peter Manser34- Jeremy Selie34- Jeremy Selier35- Jens Diemer36- Alex <@alopatin>37- Tom Hogans <tomhsx@gmail.com>
modified:HISTORY.rst+3 added-3 removed
1History2-------3450.6.0 (2011-09-??)50.6.0 (2011-08-17)6++++++++++++++++++78* New callback hook system9* New persistient sessions object and context manager10* Transparent Dict-cookie handling11* status code reference object11* Status code reference object12* Removed Response.cached13* Added Response.request14* all args are kwargs14* All args are kwargs15* Relative redirect support16* HTTPError handling improvements17* Improved https testing18* Bugfixes
132 unmodified lines
modified:README.rst+27 added-77 removed
1Requests: HTTP for Humans2=========================34Most existing Python modules for dealing HTTP requests are insane. I have to look up *everything* that I want to do. Most of my worst Python experiences are a result of the various built-in HTTP libraries (yes, even worse than Logging).4Requests is an ISC Licensed HTTP library, written in Python, for human5beings.66But this one's different. This one's going to be awesome. And simple.7Most existing Python modules for sending HTTP requests are extremely8verbose and cumbersome. Python's builtin urllib2 module provides most of9the HTTP capabilities you should need, but the api is thoroughly broken.10It requires an enormous amount of work (even method overrides) to11perform the simplest of tasks.128Really simple.13Things shouldn't be this way. Not in Python.1415::1617 >>> r = requests.get('https://api.github.com', auth=('user', 'pass'))18 >>> r.status_code19 20420 >>> r.headers['content-type']21 'application/json'22 >>> r.content23 ...2425See `the same code, without Requests <https://gist.github.com/973705>`_.2627Requests allow you to send **HEAD**, **GET**, **POST**, **PUT**,28**PATCH**, and **DELETE** HTTP requests. You can add headers, form data,29multipart files, and parameters with simple Python dictionaries, and access the30response data in the same way. It's powered by urllib2, but it does31all the hard work and crazy hacks for you.323334Features35--------3637- Extremely simple HEAD, GET, POST, PUT, PATCH, DELETE Requests
40 unmodified lines
78 >>> r.content79 '{"authenticated": true, "user": "user"}'80815859API60---6162**Requests:**6364All request functions return a Response object (see below).6566If a {filename: fileobject} dictionary is passed in (files=...), a multipart_encode upload will be performed.67If CookieJar object is is passed in (cookies=...), the cookies will be sent with the request.6869 HEAD Requests70 >>> requests.head(url, params={}, headers={}, cookies=None, auth=None, timeout=None, proxies={})71 <Response [200]>7273 GET Requests74 >>> requests.get(url, params={}, headers={}, cookies=None, auth=None, timeout=None, proxies={})75 <Response [200]>7677 POST Requests78 >>> requests.post(url, data={}, headers={}, files={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})79 <Response [200]>8081 PUT Requests82 >>> requests.put(url, data={}, headers={}, files={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})83 <Response [200]>8485 PATCH Requests86 >>> requests.patch(url, data={}, headers={}, files={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})87 <Response [200]>8889 DELETE Requests90 >>> requests.delete(url, params={}, headers={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})91 <Response [200]>929394**Responses:**9596 Response.status_code97 (Integer) Received HTTP Status Code Response9899 Response.headers100 ((CaseInsensitive) Dictionary) Received HTTP Response Headers.101102 Response.content103 (Bytes) Received Content.104105 Response.history106 (List of Responses) Redirection History.107108 Response.url109 (String) URL of response. Useful for detecting redirects.110111 Response.ok112 (Bool) True if no errors occurred during the request, and the status_code is kosher.113114 Response.cached115 (Bool) True if Response.content is stored within the object.116117 Response.error118 (HTTPError) If an HTTPError occurred (e.g. status of 404), Otherwise this is None.119120 Response.raise_for_status()121 Raises HTTPError if a request is not kosher.122123124**HTTP Authentication Registry:**125126 You can register AuthObjects to automatically enable HTTP Authentication on requests that contain a registered base URL string.127128 >>> requests.auth_manager.add_auth(url, authobject)12913013182Installation83------------8485To install requests, simply: ::
25 unmodified lines