aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http/cookies.py
diff options
context:
space:
mode:
authorShadab Zafar <dufferzafar0@gmail.com>2016-09-06 11:39:49 +0530
committerShadab Zafar <dufferzafar0@gmail.com>2016-09-27 16:44:09 +0530
commit29046e6b4881bde9d8823a01879b8fe87bdf15e0 (patch)
treee920c02552901bdaf8c140d248a8cf76e31cf9b5 /netlib/http/cookies.py
parent734a7d8a6831b17313091a80817b30403118132f (diff)
downloadmitmproxy-29046e6b4881bde9d8823a01879b8fe87bdf15e0.tar.gz
mitmproxy-29046e6b4881bde9d8823a01879b8fe87bdf15e0.tar.bz2
mitmproxy-29046e6b4881bde9d8823a01879b8fe87bdf15e0.zip
Move CookieAttrs and SetCookie to top
Diffstat (limited to 'netlib/http/cookies.py')
-rw-r--r--netlib/http/cookies.py32
1 files changed, 14 insertions, 18 deletions
diff --git a/netlib/http/cookies.py b/netlib/http/cookies.py
index 2a1f62f0..9b93e600 100644
--- a/netlib/http/cookies.py
+++ b/netlib/http/cookies.py
@@ -28,8 +28,21 @@ _cookie_params = set((
'secure', 'httponly', 'version',
))
+ESCAPE = re.compile(r"([\"\\])")
-# TODO: Disallow LHS-only Cookie values
+
+class CookieAttrs(multidict.ImmutableMultiDict):
+ @staticmethod
+ def _kconv(key):
+ return key.lower()
+
+ @staticmethod
+ def _reduce_values(values):
+ # See the StickyCookieTest for a weird cookie that only makes sense
+ # if we take the last part.
+ return values[-1]
+
+SetCookie = collections.namedtuple("SetCookie", ["value", "attrs"])
def _read_until(s, start, term):
@@ -90,7 +103,6 @@ def _read_value(s, start, delims):
return _read_until(s, start, delims)
-# TODO: Disallow LHS-only Cookie values
def _read_pairs(s, off=0):
"""
Read pairs of lhs=rhs values while handling multiple cookies.
@@ -145,9 +157,6 @@ def _has_special(s):
return False
-ESCAPE = re.compile(r"([\"\\])")
-
-
def _format_pairs(lst, specials=(), sep="; "):
"""
specials: A lower-cased list of keys that will not be quoted.
@@ -190,19 +199,6 @@ def parse_set_cookie_headers(headers):
return ret
-class CookieAttrs(multidict.ImmutableMultiDict):
- @staticmethod
- def _kconv(key):
- return key.lower()
-
- @staticmethod
- def _reduce_values(values):
- # See the StickyCookieTest for a weird cookie that only makes sense
- # if we take the last part.
- return values[-1]
-
-
-SetCookie = collections.namedtuple("SetCookie", ["value", "attrs"])
def parse_set_cookie_header(line):