From cde5a4a5d50ba967813e1bb35041eaa5f7dd2264 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 15 Jul 2014 18:23:52 +0900 Subject: [PATCH 1/3] Add Timeout exception in API documentation The Timeout exception is referenced from quickstart.rst but does not get hyperlinked. Change-Id: I69ad881bf9d2475c6239ac7b17f68ddbce0d03cd --- docs/api.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/api.rst b/docs/api.rst index 86061be9..5e22814a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -53,6 +53,7 @@ Exceptions .. autoexception:: requests.exceptions.HTTPError .. autoexception:: requests.exceptions.URLRequired .. autoexception:: requests.exceptions.TooManyRedirects +.. autoexception:: requests.exceptions.Timeout Status Code Lookup From f5a2138e8ce658d7bf3883c14805589218b06a5f Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 15 Jul 2014 18:26:30 +0900 Subject: [PATCH 2/3] Minor tidy-ups in quickstart documentation Change-Id: Ia862c17707a2a76182c549db88821636e8402729 --- docs/user/quickstart.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index 53ee6f6e..28e44977 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -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) @@ -424,7 +424,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 From a8a4c9828aea6f5159cddc2786d4a74426f9dd4f Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 15 Jul 2014 18:26:51 +0900 Subject: [PATCH 3/3] Restructure "Redirection and History" section in quickstart documentation Change-Id: Ida38d551e8cd0edaeb92d09de411a6f4a3d0578b --- docs/user/quickstart.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index 28e44977..128c5780 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -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 [] -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::