diff options
| author | Pascal Van Acker <vanacker.pascal@outlook.com> | 2017-08-28 10:58:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-28 10:58:44 +0200 |
| commit | 785c733415d605e332ca608cbabcb9dfe0442f88 (patch) | |
| tree | f69240a09c8f06492876abcb9e4cd48962359d5b /docs | |
| parent | 369be8afd07e7a0f38bc4f78d6f3764a800711aa (diff) | |
| download | python-requests-785c733415d605e332ca608cbabcb9dfe0442f88.tar.gz | |
Add environment info to prepared requests
When using prepared requests, the environment is not taken into account. This should be reflected in the documentation.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/user/advanced.rst | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index 4aa1dfac..c7f960fa 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -187,6 +187,25 @@ applied, replace the call to :meth:`Request.prepare() print(resp.status_code) +When you are using the prepared request flow, keep in mind that it does not take into account the environment. +This can cause problems if you are using environment variables to change the behaviour of requests. +For example: Self-signed SSL certificates specified in ``REQUESTS_CA_BUNDLE`` will not be taken into account. +As a result an ``SSL: CERTIFICATE_VERIFY_FAILED`` is thrown. +You can get around this behaviour by explicity merging the environment settings into your session: + + from requests import Request, Session + + s = Session() + req = Request('GET', url) + + prepped = s.prepare_request(req) + + # Merge environment settings into session + settings = s.merge_environment_settings(prepped.url, None, None, None, None) + resp = s.send(prepped, **settings) + + print(resp.status_code) + .. _verification: SSL Cert Verification |
