Docs: Clarify that method-level params are not persisted in sessions.

This commit is contained in:
Lukas Graf
2015-08-08 00:19:10 +02:00
parent 313143959e
commit 1bb91653cc
2 changed files with 20 additions and 0 deletions
+2
View File
@@ -81,6 +81,8 @@ Status Code Lookup
>>> requests.codes['\o/']
200
.. _api-cookies:
Cookies
~~~~~~~
+18
View File
@@ -45,6 +45,24 @@ Any dictionaries that you pass to a request method will be merged with the
session-level values that are set. The method-level parameters override session
parameters.
Note, however, that method-level parameters will *not* be persisted across
requests, even if using a session. This example will only send the cookies
with the first request, but not the second::
s = requests.Session()
r = s.get('http://httpbin.org/cookies', cookies={'from-my': 'browser'})
print(r.text)
# '{"cookies": {"from-my": "browser"}}'
r = s.get('http://httpbin.org/cookies')
print(r.text)
# '{"cookies": {}}'
If you want to manually add cookies to your session, use the
:ref:`Cookie utility functions <api-cookies>` to manipulate
:attr:`Session.cookies <requests.Session.cookies>`.
Sessions can also be used as context managers::
with requests.Session() as s: