Skip to content
Myr

Add environment info to prepared requests

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

When using prepared requests, the environment is not taken into account. This should be reflected in the documentation.

authored by Pascal Van Acker · committed by GitHub · parent 369be8a · Browse files · 1 file+19 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+19 added−0 removed

  • other:+19 added−0 removed

1 file+19 added−0 removed

modified:docs/user/advanced.rst+19 added
185 unmodified lines
186 )187188 print(resp.status_code)189190When you are using the prepared request flow, keep in mind that it does not take into account the environment.191This can cause problems if you are using environment variables to change the behaviour of requests.192For example: Self-signed SSL certificates specified in ``REQUESTS_CA_BUNDLE`` will not be taken into account.193As a result an ``SSL: CERTIFICATE_VERIFY_FAILED`` is thrown.194You can get around this behaviour by explicity merging the environment settings into your session:195196 from requests import Request, Session197 198 s = Session()199 req = Request('GET', url)200 201 prepped = s.prepare_request(req)202 203 # Merge environment settings into session204 settings = s.merge_environment_settings(prepped.url, None, None, None, None)205 resp = s.send(prepped, **settings)206 207 print(resp.status_code)208 209.. _verification:210211SSL Cert Verification212---------------------
797 unmodified lines