From: Cory Benfield Date: Sat, 22 Dec 2012 11:03:29 +0000 (+0000) Subject: Update session documentation. X-Git-Tag: v1.0.4~30^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1790b1df172aaef9bb86858169abec0d8849311f;p=services%2Fpython-requests.git Update session documentation. --- diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index 1947bf3..0d1db9c 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -26,12 +26,15 @@ Let's persist some cookies across requests:: # '{"cookies": {"sessioncookie": "123456789"}}' -Sessions can also be used to provide default data to the request methods:: +Sessions can also be used to provide default data to the request methods. This +is done by providing data to the properties on a session object:: headers = {'x-test': 'true'} auth = ('user', 'pass') - with requests.session(auth=auth, headers=headers) as c: + with requests.session() as c: + c.auth = auth + c.headers = headers # both 'x-test' and 'x-test2' are sent c.get('http://httpbin.org/headers', headers={'x-test2': 'true'})