Coverage for /Users/davegaeddert/Developer/dropseed/plain/plain/plain/http/cookie.py: 100%

1 from http import cookies

2

3

4 def parse_cookie(cookie):

5 """

6 Return a dictionary parsed from a `Cookie:` header string.

7 """

8 cookiedict = {}

9 for chunk in cookie.split(";"):

10 if "=" in chunk:

11 key, val = chunk.split("=", 1)

12 else:

13 # Assume an empty name per

14 # https://bugzilla.mozilla.org/show_bug.cgi?id=169091

15 key, val = "", chunk

16 key, val = key.strip(), val.strip()

17 if key or val:

18 # unquote using Python's algorithm.

19 cookiedict[key] = cookies._unquote(val)

20 return cookiedict