From 53bd5c4d217d974a71a2de64b4173766e03925a9 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Tue, 7 Jul 2020 17:25:28 +0100 Subject: [PATCH] Remove HttpUrl.getheader() --- linkcheck/checker/httpurl.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/linkcheck/checker/httpurl.py b/linkcheck/checker/httpurl.py index 3ed13041..9984e3ef 100644 --- a/linkcheck/checker/httpurl.py +++ b/linkcheck/checker/httpurl.py @@ -110,7 +110,7 @@ class HttpUrl(internpaturl.InternPatternUrl, proxysupport.ProxySupport): # Note that content-encoding causes size differences since # the content data is always decoded. try: - self.size = int(self.getheader("Content-Length")) + self.size = int(self.headers["Content-Length"]) except (ValueError, OverflowError): pass else: @@ -284,17 +284,6 @@ class HttpUrl(internpaturl.InternPatternUrl, proxysupport.ProxySupport): # run connection plugins for old connection self.aggregate.plugin_manager.run_connection_plugins(self) - def getheader(self, name, default=None): - """Get header value. - - @return: header value or default of not found - @rtype: str - """ - value = self.headers.get(name) - if value is None: - return default - return value - def check_response(self): """Check final result and log it.""" if ( @@ -314,7 +303,8 @@ class HttpUrl(internpaturl.InternPatternUrl, proxysupport.ProxySupport): if self.url_connection.status_code == 429: self.add_warning( - "Rate limited (Retry-After: %s)" % self.getheader(_("Retry-After")), + "Rate limited (Retry-After: %s)" + % self.headers.get(_("Retry-After")), tag=WARN_URL_RATE_LIMITED, )