]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(base): Fix reporting proxy error
authorOleg Broytman <phd@phdru.name>
Thu, 22 Aug 2024 22:22:39 +0000 (01:22 +0300)
committerOleg Broytman <phd@phdru.name>
Sat, 7 Sep 2024 10:59:02 +0000 (13:59 +0300)
Robots/base.py

index b165c9b341746f3640adc55347bee15884cc0c74..3aaac77acc9c39735b9d35f5b0c3eab2134141e8 100644 (file)
@@ -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)
         ):