[docs]defparse_cookie(cookie):""" Return a dictionary parsed from a `Cookie:` header string. """cookiedict={}forchunkincookie.split(str(";")):ifstr("=")inchunk:key,val=chunk.split(str("="),1)else:# Assume an empty name per# https://bugzilla.mozilla.org/show_bug.cgi?id=169091key,val=str(""),chunkkey,val=key.strip(),val.strip()ifkeyorval:# unquote using Python's algorithm.cookiedict[key]=http.cookies._unquote(val)returncookiedict