From 28fb064d9a5652c1e3f99524081e07b1509c5b33 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 23 Aug 2024 01:22:39 +0300 Subject: [PATCH] Fix(base): Fix reporting proxy error --- Robots/base.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Robots/base.py b/Robots/base.py index b165c9b..3aaac77 100644 --- a/Robots/base.py +++ b/Robots/base.py @@ -382,17 +382,21 @@ class robot_base(Robot): else: error, http_status_code, resp_headers, content = \ await self.get(url, req_headers) - if error is not None and ( - not url_host.startswith('localhost') and - not url_host.startswith('127.') - ): + if error is None or \ + url_host.startswith('localhost') or \ + url_host.startswith('127.'): + use_proxy = False + else: self.log(' Error : %s' % error) - if use_proxy and http_status_code != 404: - self.log(' Retrying with the proxy...') - error, http_status_code, resp_headers, content = \ - await self.get(url, req_headers, use_proxy=True) - if error is None: - self.proxy_ok.add(url_host) + if use_proxy: + if http_status_code == 404: + use_proxy = False + else: + self.log(' Retrying with the proxy...') + error, http_status_code, resp_headers, content = \ + await self.get(url, req_headers, use_proxy=True) + if error is None: + self.proxy_ok.add(url_host) if (error is not None) or ( http_status_code and (http_status_code >= 400) ): -- 2.39.5