From 03feaeca910e2a9ecee866848b56cc94cea7b99c Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Wed, 18 May 2011 20:56:31 +0200 Subject: [PATCH] Correct warning about unparsable cookies. --- linkcheck/checker/httpurl.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/linkcheck/checker/httpurl.py b/linkcheck/checker/httpurl.py index e6af5950..e674f8f0 100644 --- a/linkcheck/checker/httpurl.py +++ b/linkcheck/checker/httpurl.py @@ -25,7 +25,6 @@ import errno import zlib import socket from cStringIO import StringIO -import Cookie from .. import (log, LOG_CHECK, gzip2 as gzip, strformat, url as urlutil, httplib2 as httplib, LinkCheckerError, configuration, get_link_pat) @@ -288,7 +287,7 @@ class HttpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport): """Return content MIME type or empty string.""" if self.content_type is None: if self.headers: - self.content_type = headers.get_content_type(self.headers) + self.content_type = headers.get_content_type(self.headers) else: self.content_type = u"" return self.content_type @@ -468,14 +467,11 @@ class HttpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport): for c in self.cookies: self.add_info(_("Sent cookie: %(cookie)s.") % {"cookie": c}) - try: - out = self.aggregate.cookies.add(self.headers, - self.urlparts[0], - self.urlparts[1], - self.urlparts[2]) - except Cookie.CookieError, msg: - self.add_warning(_("Could not store cookies: %(msg)s.") % - {'msg': str(msg)}, + jar = self.aggregate.cookies.add(self.headers, self.urlparts[0], + self.urlparts[1], self.urlparts[2]) + if not jar: + self.add_warning(_("Could not store cookies from headers: %(headers)s.") % + {'headers': str(self.headers)}, tag=WARN_HTTP_COOKIE_STORE_ERROR) if response.status >= 200: self.set_result(u"%r %s" % (response.status, response.reason))