Skip to content
Myr

Improve the PreparedRequest docs.

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 · parent 7b5c11f · Browse files · 1 file+30 added−0 removed
This commit

State

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

Diff stats

1 file+30 added−0 removed

  • other:+30 added−0 removed

1 file+30 added−0 removed

modified:docs/user/advanced.rst+30 added
110 unmodified lines
111prepare it immediately and modified the ``PreparedRequest`` object. You then112send that with the other parameters you would have sent to ``requests.*`` or113``Sesssion.*``.114115However, the above code will lose some of the advantages of having a Requests116:class:`Session <requests.Session>` object. In particular,117:class:`Session <requests.Session>`-level state such as cookies will118not get applied to your request. To get a119:class:`PreparedRequest <requests.models.PreparedRequest>` with that state120applied, replace the call to ``Request.prepare()`` with a call to121``Session.prepare_request()``, like this::122123 from requests import Request, Session124125 s = Session()126 req = Request('GET', # or any other method, 'POST', 'PUT', etc.127 url,128 data=data129 headers=headers130 # ...131 )132 prepped = s.prepare_request(req)133 # do something with prepped.body134 # do something with prepped.headers135 resp = s.send(prepped,136 stream=stream,137 verify=verify,138 proxies=proxies,139 cert=cert,140 timeout=timeout,141 # etc.142 )143 print(resp.status_code)144145SSL Cert Verification146---------------------147148Requests can verify SSL certificates for HTTPS requests, just like a web browser. To check a host's SSL certificate, you can use the ``verify`` argument::
478 unmodified lines