def cookies(self): if self._cookies is None: parser = BaseCookie() cookie_headers = self.headers.get("cookie", b"") parser.load(cookie_headers) cookies = Cookies() for key, value in parser.iteritems(): cookies[key] = CookieValue(value) self._cookies = cookies return self._cookies
def cookies(self): if self._cookies is None: parser = BaseCookie() cookie_headers = self.headers.get("cookie", b"") if PY3: cookie_headers = cookie_headers.decode("iso-8859-1") parser.load(cookie_headers) cookies = Cookies() for key, value in iteritems(parser): cookies[key] = CookieValue(value) self._cookies = cookies return self._cookies
def unset_cookie(self, name): """Remove a cookie from those that are being sent with the response""" cookies = self.headers.get("Set-Cookie") parser = BaseCookie() for cookie in cookies: parser.load(cookie) if name in parser.keys(): del self.headers["Set-Cookie"] for m in parser.values(): if m.key != name: self.headers.append(("Set-Cookie", m.OutputString()))
def unset_cookie(self, name): """Remove a cookie from those that are being sent with the response""" if PY3: name = isomorphic_decode(name) cookies = self.headers.get("Set-Cookie") parser = BaseCookie() for cookie in cookies: if PY3: # BaseCookie.load expects a text string. cookie = isomorphic_decode(cookie) parser.load(cookie) if name in parser.keys(): del self.headers["Set-Cookie"] for m in parser.values(): if m.key != name: self.headers.append(("Set-Cookie", m.OutputString()))