From 415efe262e5fd2fea7cd86f051aee5425c55ba68 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Wed, 13 Oct 2010 22:35:36 +0200 Subject: [PATCH] Added equality check for Cookies, and use that to augment the retrieved cookies. --- linkcheck/cache/cookie.py | 2 +- linkcheck/cookies.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/linkcheck/cache/cookie.py b/linkcheck/cache/cookie.py index 76cb2bea..46d3be37 100644 --- a/linkcheck/cache/cookie.py +++ b/linkcheck/cache/cookie.py @@ -36,7 +36,7 @@ class CookieJar (object): @synchronized(_lock) def add (self, headers, scheme, host, path): """Parse cookie values, add to cache.""" - jar = set() + jar = self.cache.setdefault(host, set()) for h in headers.getallmatchingheaders("Set-Cookie"): # RFC 2109 (Netscape) cookie type try: diff --git a/linkcheck/cookies.py b/linkcheck/cookies.py index 64e402e3..f9a48c10 100644 --- a/linkcheck/cookies.py +++ b/linkcheck/cookies.py @@ -279,6 +279,10 @@ class HttpCookie (object): for k, v in self.attributes.items() if k != "version"]) return "; ".join(parts) + def __eq__ (self, other): + return isinstance(other, HttpCookie) and \ + self.server_header_value() == other.server_header_value() + class NetscapeCookie (HttpCookie): """Parses RFC 2109 (Netscape) cookies.""" @@ -312,9 +316,6 @@ class Rfc2965Cookie (HttpCookie): return quote(value) -# XXX more methods (equality test) - - def from_file (filename): """Parse cookie data from a text file in HTTP header format.