====================
This repository contains sphinx styles Kenneth Reitz uses in most of
-his projects. It is a drivative of Mitsuhiko's themes for Flask and Flask related
+his projects. It is a derivative of Mitsuhiko's themes for Flask and Flask related
projects. To use this style in your Sphinx documentation, follow
this guide:
`Twitter, Inc <http://twitter.com>`_,
`Readability <http://readability.com>`_, and
Federal US Institutions
-use Requests internally. It has been installed over 45,000 times from PyPi.
+use Requests internally. It has been installed over 45,000 times from PyPI.
**Armin Ronacher**
Requests is the perfect example how beautiful an API can be with the
---------------
The Session object allows you to persist certain parameters across
-requests. It also perstists cookies across all requests made from the
+requests. It also persists cookies across all requests made from the
Session instance.
A session object has all the methods of the main Requests API.
Body Content Workflow
----------------------
-By default, When you make a request, the body of the response isn't downloaded immediately. The response headers are downloaded when you make a request, but the content isn't downloaded until you access the :class:`Response.content` attribute.
+By default, when you make a request, the body of the response isn't downloaded immediately. The response headers are downloaded when you make a request, but the content isn't downloaded until you access the :class:`Response.content` attribute.
Let's walk through it::
Asynchronous Requests
----------------------
-Requests has first-class support for concurrent requests, powered
-by gevent. This allows you to send a bunch of HTTP requests at the same
+Requests has first-class support for concurrent requests, powered by gevent.
+This allows you to send a bunch of HTTP requests at the same time.
First, let's import the async module. Heads up — if you don't have
`gevent <http://pypi.python.org/pypi/gevent>`_ this will fail::
def __init__(self, username):
# setup any auth-related data here
self.username = username
-
+
def __call__(self, r):
# modify and return the request
r.headers['X-Pizza'] = self.username
Redirection and History
-----------------------
-Requests will automatically perform location redirection while using impodotent methods.
+Requests will automatically perform location redirection while using idempotent methods.
GitHub redirects all HTTP requests to HTTPS. Let's see what happens::
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of 'name': file-like-objects (or {'name': ('filename', fileobj)}) for multipart encoding upload.
- :param auth: (optional) Auth typle to enable Basic/Digest/Custom HTTP Auth.
+ :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:base_headers: Default HTTP headers.
:verbose: Stream to write request logging to.
:timeout: Seconds until request timeout.
-:max_redirects: Maximum njumber of redirects allowed within a request.
+:max_redirects: Maximum number of redirects allowed within a request.
:decode_unicode: Decode unicode responses automatically?
:keep_alive: Reuse HTTP Connections?
:max_retries: The number of times a request should be retried in the event of a connection failure.
request."""
class HTTPError(RequestException):
- """An HTTP error occured."""
+ """An HTTP error occurred."""
class ConnectionError(RequestException):
- """A Connection error occured."""
+ """A Connection error occurred."""
class Timeout(RequestException):
"""The request timed out."""
if resp:
- # Fallback to None if there's no staus_code, for whatever reason.
+ # Fallback to None if there's no status_code, for whatever reason.
response.status_code = getattr(resp, 'status', None)
# Make headers case-insensitive.
# Save cookies in Response.
response.cookies = cookies
- # Save original resopnse for later.
+ # Save original response for later.
response.raw = resp
if is_error:
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.
- :param auth: (optional) Auth typle to enable Basic/Digest/Custom HTTP Auth.
+ :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
requests.utils
~~~~~~~~~~~~~~
-This module provides utlity functions that are used within Requests
+This module provides utility functions that are used within Requests
that are also useful for external consumption.
"""
"""Re-quote the given URL path component.
This function passes the given path through an unquote/quote cycle to
- ensure that it is fully and consistenty quoted.
+ ensure that it is fully and consistently quoted.
"""
parts = path.split("/")
parts = (urllib.quote(urllib.unquote(part), safe="") for part in parts)