class RequestsCookieJar(cookielib.CookieJar, MutableMapping):
Compatibility class; is a cookielib.CookieJar, but exposes a dict interface.
This is the CookieJar we create by default for requests and sessions that don't specify one, since some clients may expect response.cookies and session.cookies to support dict operations.
Requests does not use the dict interface internally; it's just for compatibility with external client code. All requests code should work out of the box with externally provided instances of CookieJar, e.g. LWPCookieJar and FileCookieJar.
Unlike a regular CookieJar, this class is pickleable.
Warning
dictionary operations that are normally O(1) may be O(n).
Method | copy |
Return a copy of this RequestsCookieJar. |
Method | get |
Dict-like get() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains. |
Method | get_dict |
Takes as an argument an optional domain and path and returns a plain old Python dict of name-value pairs of cookies that meet the requirements. |
Method | get_policy |
Return the CookiePolicy instance used. |
Method | items |
Dict-like items() that returns a list of name-value tuples from the jar. Allows client-code to call dict(RequestsCookieJar) and get a vanilla python dict of key value pairs. |
Method | iteritems |
Dict-like iteritems() that returns an iterator of name-value tuples from the jar. |
Method | iterkeys |
Dict-like iterkeys() that returns an iterator of names of cookies from the jar. |
Method | itervalues |
Dict-like itervalues() that returns an iterator of values of cookies from the jar. |
Method | keys |
Dict-like keys() that returns a list of names of cookies from the jar. |
Method | list_domains |
Utility method to list all the domains in the jar. |
Method | list_paths |
Utility method to list all the paths in the jar. |
Method | multiple_domains |
Returns True if there are multiple domains in the jar. Returns False otherwise. |
Method | set |
Dict-like set() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains. |
Method | set_cookie |
Undocumented |
Method | update |
Updates this jar with cookies from another CookieJar or dict-like |
Method | values |
Dict-like values() that returns a list of values of cookies from the jar. |
Method | __contains__ |
Undocumented |
Method | __delitem__ |
Deletes a cookie given a name. Wraps cookielib.CookieJar's remove_cookie_by_name(). |
Method | __getitem__ |
Dict-like __getitem__() for compatibility with client code. Throws exception if there are more than one cookie with name. In that case, use the more explicit get() method instead. |
Method | __getstate__ |
Unlike a normal CookieJar, this class is pickleable. |
Method | __setitem__ |
Dict-like __setitem__ for compatibility with client code. Throws exception if there is already a cookie of that name in the jar. In that case, use the more explicit set() method instead. |
Method | __setstate__ |
Unlike a normal CookieJar, this class is pickleable. |
Method | _find |
Requests uses this method internally to get cookie values. |
Method | _find_no_duplicates |
Both __get_item__ and get call this function: it's never used elsewhere in Requests. |
Instance Variable | _cookies_lock |
Undocumented |
Dict-like get() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains.
Warning
operation is O(n), not O(1).
Returns | |
dict | Undocumented |
Dict-like items() that returns a list of name-value tuples from the jar. Allows client-code to call dict(RequestsCookieJar) and get a vanilla python dict of key value pairs.
See Also
keys() and values().
Dict-like iteritems() that returns an iterator of name-value tuples from the jar.
See Also
iterkeys() and itervalues().
Dict-like iterkeys() that returns an iterator of names of cookies from the jar.
See Also
itervalues() and iteritems().
Dict-like itervalues() that returns an iterator of values of cookies from the jar.
See Also
iterkeys() and iteritems().
Dict-like keys() that returns a list of names of cookies from the jar.
See Also
values() and items().
Returns | |
bool | Undocumented |
Dict-like values() that returns a list of values of cookies from the jar.
See Also
keys() and items().
Dict-like __getitem__() for compatibility with client code. Throws exception if there are more than one cookie with name. In that case, use the more explicit get() method instead.
Warning
operation is O(n), not O(1).
Requests uses this method internally to get cookie values.
If there are conflicting cookies, _find arbitrarily chooses one. See _find_no_duplicates if you want an exception thrown if there are conflicting cookies.
Parameters | |
name | a string containing name of cookie |
domain | (optional) string containing domain of cookie |
path | (optional) string containing path of cookie |
Returns | |
cookie.value |
Parameters | |
name | a string containing name of cookie |
domain | (optional) string containing domain of cookie |
path | (optional) string containing path of cookie |
Returns | |
cookie.value | |
Raises | |
KeyError | if cookie is not found |
CookieConflictError | if there are multiple cookies that match name and optionally domain and path |