mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #2131 from dpursehouse/quickstart-doc-updates
Quickstart doc updates
This commit is contained in:
@@ -53,6 +53,7 @@ Exceptions
|
||||
.. autoexception:: requests.exceptions.HTTPError
|
||||
.. autoexception:: requests.exceptions.URLRequired
|
||||
.. autoexception:: requests.exceptions.TooManyRedirects
|
||||
.. autoexception:: requests.exceptions.Timeout
|
||||
|
||||
|
||||
Status Code Lookup
|
||||
|
||||
@@ -340,7 +340,7 @@ So, we can access the headers using any capitalization we want::
|
||||
Cookies
|
||||
-------
|
||||
|
||||
If a response contains some Cookies, you can get quick access to them::
|
||||
If a response contains some Cookies, you can quickly access them::
|
||||
|
||||
>>> url = 'http://example.com/some/cookie/setting/url'
|
||||
>>> r = requests.get(url)
|
||||
@@ -362,11 +362,16 @@ parameter::
|
||||
Redirection and History
|
||||
-----------------------
|
||||
|
||||
Requests will automatically perform location redirection for all verbs except
|
||||
By default Requests will perform location redirection for all verbs except
|
||||
HEAD.
|
||||
|
||||
GitHub redirects all HTTP requests to HTTPS. We can use the ``history`` method
|
||||
of the Response object to track redirection. Let's see what GitHub does::
|
||||
We can use the ``history`` property of the Response object to track redirection.
|
||||
|
||||
The :meth:`Response.history` list contains the :class:`Request` objects that
|
||||
were created in order to complete the request. The list is sorted from the
|
||||
oldest to the most recent request.
|
||||
|
||||
For example, GitHub redirects all HTTP requests to HTTPS::
|
||||
|
||||
>>> r = requests.get('http://github.com')
|
||||
>>> r.url
|
||||
@@ -376,9 +381,6 @@ of the Response object to track redirection. Let's see what GitHub does::
|
||||
>>> r.history
|
||||
[<Response [301]>]
|
||||
|
||||
The :class:`Response.history` list contains the :class:`Request` objects that
|
||||
were created in order to complete the request. The list is sorted from the
|
||||
oldest to the most recent request.
|
||||
|
||||
If you're using GET, OPTIONS, POST, PUT, PATCH or DELETE, you can disable
|
||||
redirection handling with the ``allow_redirects`` parameter::
|
||||
@@ -424,7 +426,7 @@ Errors and Exceptions
|
||||
In the event of a network problem (e.g. DNS failure, refused connection, etc),
|
||||
Requests will raise a :class:`~requests.exceptions.ConnectionError` exception.
|
||||
|
||||
In the event of the rare invalid HTTP response, Requests will raise an
|
||||
In the rare event of an invalid HTTP response, Requests will raise an
|
||||
:class:`~requests.exceptions.HTTPError` exception.
|
||||
|
||||
If a request times out, a :class:`~requests.exceptions.Timeout` exception is
|
||||
|
||||
Reference in New Issue
Block a user