Beispiel #1
0
def test_cookie_roundtrips():
    for s, expected in cookie_pairs:
        ret = cookies.parse_cookie_header(s)
        assert ret == expected

        s2 = cookies.format_cookie_header(expected)
        ret = cookies.parse_cookie_header(s2)
        assert ret == expected
Beispiel #2
0
def test_cookie_roundtrips():
    for s, expected in cookie_pairs:
        ret = cookies.parse_cookie_header(s)
        assert ret == expected

        s2 = cookies.format_cookie_header(expected)
        ret = cookies.parse_cookie_header(s2)
        assert ret == expected
Beispiel #3
0
def test_cookie_roundtrips():
    pairs = [
        ["one=uno", [["one", "uno"]]],
        ["one=uno; two=due", [["one", "uno"], ["two", "due"]]],
    ]
    for s, lst in pairs:
        ret = cookies.parse_cookie_header(s)
        nose.tools.eq_(ret.lst, lst)
        s2 = cookies.format_cookie_header(ret)
        ret = cookies.parse_cookie_header(s2)
        nose.tools.eq_(ret.lst, lst)
Beispiel #4
0
def test_cookie_roundtrips():
    pairs = [
        ["one=uno", [["one", "uno"]]],
        ["one=uno; two=due", [["one", "uno"], ["two", "due"]]],
    ]
    for s, lst in pairs:
        ret = cookies.parse_cookie_header(s)
        assert ret.lst == lst
        s2 = cookies.format_cookie_header(ret)
        ret = cookies.parse_cookie_header(s2)
        assert ret.lst == lst
Beispiel #5
0
 def handle_request(self, f):
     l = []
     if f.match(self.flt):
         for domain, port, path in self.jar.keys():
             match = [
                 self.domain_match(f.request.host, domain),
                 f.request.port == port,
                 f.request.path.startswith(path)
             ]
             if all(match):
                 c = self.jar[(domain, port, path)]
                 l.extend([cookies.format_cookie_header(c[name].items(multi=True)) for name in c.keys()])
     if l:
         f.request.stickycookie = True
         f.request.headers["cookie"] = "; ".join(l)
Beispiel #6
0
 def handle_request(self, f):
     l = []
     if f.match(self.flt):
         for i in self.jar.keys():
             match = [
                 self.domain_match(f.request.host, i[0]),
                 f.request.port == i[1],
                 f.request.path.startswith(i[2])
             ]
             if all(match):
                 c = self.jar[i]
                 l.extend([cookies.format_cookie_header(c[name]) for name in c.keys()])
     if l:
         f.request.stickycookie = True
         f.request.headers["cookie"] = "; ".join(l)
 def handle_request(self, f):
     l = []
     if f.match(self.flt):
         for domain, port, path in self.jar.keys():
             match = [
                 self.domain_match(f.request.host, domain),
                 f.request.port == port,
                 f.request.path.startswith(path)
             ]
             if all(match):
                 c = self.jar[(domain, port, path)]
                 l.extend([cookies.format_cookie_header(c[name].items(multi=True)) for name in c.keys()])
     if l:
         f.request.stickycookie = True
         f.request.headers["cookie"] = "; ".join(l)
def test_cookie_roundtrips():
    pairs = [
        [
            "one=uno",
            [["one", "uno"]]
        ],
        [
            "one=uno; two=due",
            [["one", "uno"], ["two", "due"]]
        ],
    ]
    for s, lst in pairs:
        ret = cookies.parse_cookie_header(s)
        assert ret.lst == lst
        s2 = cookies.format_cookie_header(ret)
        ret = cookies.parse_cookie_header(s2)
        assert ret.lst == lst
Beispiel #9
0
 def request(self, flow):
     if self.flt:
         l = []
         if flow.match(self.flt):
             for domain, port, path in self.jar.keys():
                 match = [
                     domain_match(flow.request.host, domain),
                     flow.request.port == port,
                     flow.request.path.startswith(path)
                 ]
                 if all(match):
                     c = self.jar[(domain, port, path)]
                     l.extend([cookies.format_cookie_header(c[name].items(multi=True)) for name in c.keys()])
         if l:
             # FIXME: we need to formalise this...
             flow.request.stickycookie = True
             flow.request.headers["cookie"] = "; ".join(l)
def test_cookie_roundtrips():
    pairs = [
        [
            "one=uno",
            [["one", "uno"]]
        ],
        [
            "one=uno; two=due",
            [["one", "uno"], ["two", "due"]]
        ],
    ]
    for s, lst in pairs:
        ret = cookies.parse_cookie_header(s)
        nose.tools.eq_(ret.lst, lst)
        s2 = cookies.format_cookie_header(ret)
        ret = cookies.parse_cookie_header(s2)
        nose.tools.eq_(ret.lst, lst)
Beispiel #11
0
 def request(self, flow):
     if self.flt:
         l = []
         if flow.match(self.flt):
             for domain, port, path in self.jar.keys():
                 match = [
                     domain_match(flow.request.host, domain),
                     flow.request.port == port,
                     flow.request.path.startswith(path)
                 ]
                 if all(match):
                     c = self.jar[(domain, port, path)]
                     l.extend([cookies.format_cookie_header(c[name].items(multi=True)) for name in c.keys()])
         if l:
             # FIXME: we need to formalise this...
             flow.request.stickycookie = True
             flow.request.headers["cookie"] = "; ".join(l)
Beispiel #12
0
 def _set_cookies(self, value):
     self.headers["cookie"] = cookies.format_cookie_header(value)
Beispiel #13
0
 def cookies(self, odict):
     self.headers["cookie"] = cookies.format_cookie_header(odict)
Beispiel #14
0
 def cookies(self, odict):
     self.headers["cookie"] = cookies.format_cookie_header(odict)
Beispiel #15
0
 def _set_cookies(self, value):
     self.headers["cookie"] = cookies.format_cookie_header(value)