From: Kenneth Reitz Date: Sat, 12 Nov 2011 23:23:26 +0000 (-0500) Subject: redirection docs X-Git-Tag: v0.8.0~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=30377ca91211725aacf41905c5998cd4ed36a900;p=services%2Fpython-requests.git redirection docs --- diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index a8c8274..b77bd29 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -247,6 +247,43 @@ Another popular form of web service protection is Digest Authentication:: +Redirection and History +----------------------- + +Requests will automatically perform location redirection while using impodotent methods. + +GitHub redirects all HTTP requests to HTTPS. Let's see what happens:: + + >>> r = request.get('http://github.com') + >>> r.url + 'https://github.com/' + >>> r.status_code + 200 + >>> r.history + [] + +The :class:`Response.history` list contains a list of the +:class:`Request` objects that were created in order to complete the request. + +If you're using GET, HEAD, or OPTIONS, you can disable redirection +handling with the ``disable_redirects`` parameter:: + + >>> r = request.get('http://github.com') + >>> r.status_code + 301 + >>> r.history + [] + +If you're using POST, PUT, PATCH, *&c*, you can also explicitly enable redirection as well:: + + >>> r = request.post('http://github.com') + >>> r.url + 'https://github.com/' + >>> r.history + [] + + + ----------------------- Ready for more? Check out the :ref:`advanced ` section.