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
def request(self, flow: http.HTTPFlow): if self.flt: cookie_list = [] # type: List[Tuple[str,str]] if flowfilter.match(self.flt, flow): for (domain, port, path), c in self.jar.items(): match = [ domain_match(flow.request.host, domain), flow.request.port == port, flow.request.path.startswith(path) ] if all(match): cookie_list.extend(c.items()) if cookie_list: # FIXME: we need to formalise this... flow.metadata["stickycookie"] = True flow.request.headers["cookie"] = cookies.format_cookie_header(cookie_list)
def request(self, flow: http.HTTPFlow): if self.flt: cookie_list: List[Tuple[str, str]] = [] if flowfilter.match(self.flt, flow): for (domain, port, path), c in self.jar.items(): match = [ domain_match(flow.request.host, domain), flow.request.port == port, flow.request.path.startswith(path) ] if all(match): cookie_list.extend(c.items()) if cookie_list: # FIXME: we need to formalise this... flow.metadata["stickycookie"] = True flow.request.headers["cookie"] = cookies.format_cookie_header(cookie_list)
def request(self, flow): if self.flt: l = [] if flowfilter.match(self.flt, flow): 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 _set_cookies(self, value): self.headers["cookie"] = cookies.format_cookie_header(value)