module documentation

Compatibility code to be able to use cookielib.CookieJar with requests.

requests.utils imports from here, so be careful with imports.

Class ​Cookie​Conflict​Error There are two cookies that meet the criteria specified in the cookie jar. Use .get and .set and include domain and path args in order to be more specific.
Class ​Requests​Cookie​Jar Compatibility class; is a cookielib.CookieJar, but exposes a dict interface.
Function cookiejar​_from​_dict Returns a CookieJar from a key/value dictionary.
Class ​Mock​Request Wraps a requests.Request to mimic a urllib2.Request.
Class ​Mock​Response Wraps a httplib.HTTPMessage to mimic a urllib.addinfourl.
Function ​_copy​_cookie​_jar Undocumented
Function create​_cookie Make a cookie from underspecified parameters.
Function extract​_cookies​_to​_jar Extract the cookies from the response into a CookieJar.
Function get​_cookie​_header Produce an appropriate Cookie header string to be sent with request, or None.
Function merge​_cookies Add cookies to cookiejar and returns a merged CookieJar.
Function morsel​_to​_cookie Convert a Morsel object into a Cookie containing the one k/v pair.
Function remove​_cookie​_by​_name Unsets a cookie by name, by default over all domains and paths.
def cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True):
Returns a CookieJar from a key/value dictionary.
Parameters
cookie​_dictDict of key/values to insert into CookieJar.
cookiejar(optional) A cookiejar to add the cookies to.
overwrite(optional) If False, will not replace cookies already in the jar with new ones.
Returns
CookieJarUndocumented
def _copy_cookie_jar(jar):

Undocumented

def create_cookie(name, value, **kwargs):

Make a cookie from underspecified parameters.

By default, the pair of name and value will be set for the domain '' and sent on every request (this is sometimes called a "supercookie").

def extract_cookies_to_jar(jar, request, response):
Extract the cookies from the response into a CookieJar.
Parameters
jarcookielib.CookieJar (not necessarily a RequestsCookieJar)
requestour own requests.Request object
responseurllib3.HTTPResponse object
def get_cookie_header(jar, request):
Produce an appropriate Cookie header string to be sent with request, or None.
Returns
strUndocumented
def merge_cookies(cookiejar, cookies):
Add cookies to cookiejar and returns a merged CookieJar.
Parameters
cookiejarCookieJar object to add the cookies to.
cookiesDictionary or CookieJar object to be added.
Returns
CookieJarUndocumented
def morsel_to_cookie(morsel):
Convert a Morsel object into a Cookie containing the one k/v pair.
def remove_cookie_by_name(cookiejar, name, domain=None, path=None):

Unsets a cookie by name, by default over all domains and paths.

Wraps CookieJar.clear(), is O(n).