Skip to content
Myr

Merge pull request #2135 from dpursehouse/fix-meth-and-class-directives

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

authored by Cory Benfield · committed by Cory Benfield · parents d21916c, 2a6303e · Browse files · 2 files+6 added−5 removed
This commit

State

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

Trailers

  • Docs: Fix :class: and :meth: directives

Diff stats

2 files+6 added−5 removed

  • other:+6 added−5 removed

2 files+6 added−5 removed

modified:docs/user/advanced.rst+2 added-2 removed
78 unmodified lines
7980Prepared Requests81-----------------8283Whenever you receive a :class:`Response <requests.models.Response>` object83Whenever you receive a :class:`Response <requests.Response>` object84from an API call or a Session call, the ``request`` attribute is actually the85``PreparedRequest`` that was used. In some cases you may wish to do some extra86work to the body or headers (or anything else really) before sending a87request. The simple recipe for this is the following::
28 unmodified lines
116However, the above code will lose some of the advantages of having a Requests117:class:`Session <requests.Session>` object. In particular,118:class:`Session <requests.Session>`-level state such as cookies will119not get applied to your request. To get a120:class:`PreparedRequest <requests.models.PreparedRequest>` with that state120:class:`PreparedRequest <requests.PreparedRequest>` with that state121applied, replace the call to :meth:`Request.prepare()122<requests.Request.prepare>` with a call to123:meth:`Session.prepare_request() <requests.Session.prepare_request>`, like this::124
558 unmodified lines
modified:docs/user/quickstart.rst+4 added-3 removed
365 unmodified lines
366HEAD.367368We can use the ``history`` property of the Response object to track redirection.369370The :meth:`Response.history` list contains the :class:`Request` objects that371were created in order to complete the request. The list is sorted from the372oldest to the most recent request.370The :meth:`Response.history <requests.Response.history>` list contains the371:class:`Request <requests.Request>` objects that were created in order to372complete the request. The list is sorted from the oldest to the most recent373request.374375For example, GitHub redirects all HTTP requests to HTTPS::376377 >>> r = requests.get('http://github.com')
67 unmodified lines