class RequestsCookieJar(cookielib.CookieJar, MutableMapping): (source)
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 | __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 | 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 |
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 |
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 |
Utility method to list all the domains in the jar. |
Method | list |
Utility method to list all the paths in the jar. |
Method | multiple |
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 |
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 | _find |
Requests uses this method internally to get cookie values. |
Method | _find |
Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests. |
Instance Variable | _cookies |
Undocumented |
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).
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.
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).
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. :rtype: dict
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. .. seealso:: keys() and values().
Dict-like iteritems() that returns an iterator of name-value tuples from the jar. .. seealso:: iterkeys() and itervalues().
Dict-like iterkeys() that returns an iterator of names of cookies from the jar. .. seealso:: itervalues() and iteritems().
Dict-like itervalues() that returns an iterator of values of cookies from the jar. .. seealso:: iterkeys() and iteritems().
Dict-like keys() that returns a list of names of cookies from the jar. .. seealso:: values() and items().
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.
Dict-like values() that returns a list of values of cookies from the jar. .. seealso:: keys() and items().
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. :param name: a string containing name of cookie :param domain: (optional) string containing domain of cookie :param path: (optional) string containing path of cookie :return: cookie.value
Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests. :param name: a string containing name of cookie :param domain: (optional) string containing domain of cookie :param path: (optional) string containing path of cookie :raises KeyError: if cookie is not found :raises CookieConflictError: if there are multiple cookies that match name and optionally domain and path :return: cookie.value