Skip to content
Myr

explain sessions and keep alive

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 92a8db6 · Browse files · 1 file+28 added−3 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+28 added−3 removed

  • other:+28 added−3 removed

1 file+28 added−3 removed

modified:docs/user/advanced.rst+28 added-3 removed
35 unmodified lines
36 # both 'x-test' and 'x-test2' are sent37 c.get('http://httpbin.org/headers', headers={'x-test2': 'true'})383940.. admonition:: Global Settings40Any 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.4142 Certain parameters are best set in the ``config`` dictionary43 (e.g. user agent header).42.. admonition:: Remove a Value From a Dict Parameter4344 Sometimes you'll want to omit session-level keys from a dict parameter. To do this, you simply set that key's value to ``None`` in the method-level parameter. It will automatically be omitted.4546All values that are contained within a session are directly available to you:4748 Session attibutes:49 ``auth``, ``config``, ``cookies``, ``headers``, ``hooks``, ``keep_alive``, ``params``, ``proxies``, ''timeout``50515253Configuring Requests54--------------------5556Sometimes you may want to configure a request to customize it's behavior. To do57this, you can pass in a ``config`` dictionary to a request or session.585960Keep-Alive61----------6263Excellent news — keep alive is 100% automatic within a session! Couldn't be easier.6465If you'd like to disable keep-alive, you can simply set the ``keep_alive`` configuration to ``False``::6667 s = requests.session()68 s.config['keep_alive'] = False697071Asynchronous Requests72----------------------7374Requests has first-class support for non-blocking i/o requests, powered
156 unmodified lines