diff options
author | Shadab Zafar <dufferzafar0@gmail.com> | 2016-09-06 11:43:45 +0530 |
---|---|---|
committer | Shadab Zafar <dufferzafar0@gmail.com> | 2016-09-27 16:44:09 +0530 |
commit | 06804e544883de187a6f64163c18d3d63e7a3047 (patch) | |
tree | 31020795037305f88a34d0d0e954302d5f9434a2 /netlib | |
parent | 7802a0ba228df11f3c3defaf9a06c9f78745b701 (diff) | |
download | mitmproxy-06804e544883de187a6f64163c18d3d63e7a3047.tar.gz mitmproxy-06804e544883de187a6f64163c18d3d63e7a3047.tar.bz2 mitmproxy-06804e544883de187a6f64163c18d3d63e7a3047.zip |
Add a new pairs reader for SetCookie headers
Diffstat (limited to 'netlib')
-rw-r--r-- | netlib/http/cookies.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/netlib/http/cookies.py b/netlib/http/cookies.py index 3b5568c9..774b1d14 100644 --- a/netlib/http/cookies.py +++ b/netlib/http/cookies.py @@ -128,6 +128,15 @@ def _read_cookie_pairs(s, off=0): break return pairs, off + + +def _read_set_cookie_pairs(s, off=0): + """ + Read pairs of lhs=rhs values from SetCookie headers while handling multiple cookies. + + off: start offset + specials: attributes that are treated specially + """ cookies = [] pairs = [] @@ -140,10 +149,12 @@ def _read_cookie_pairs(s, off=0): if off < len(s) and s[off] == "=": rhs, off = _read_value(s, off + 1, ";,") - # expires values can contain commas in them so they need to - # be handled separately. + # Special handliing of attributes if lhs.lower() == "expires": - # This is a heuristic we use to determine whether we've + # 'expires' values can contain commas in them so they need to + # be handled separately. + + # '3' is just a heuristic we use to determine whether we've # only read a part of the datetime and should read more. if len(rhs) <= 3: trail, off = _read_value(s, off + 1, ";,") @@ -163,6 +174,7 @@ def _read_cookie_pairs(s, off=0): if pairs or not cookies: cookies.append(pairs) + return cookies, off |