]> git.phdru.name Git - bookmarks_db.git/commitdiff
Feat(Robots/bkmk_rhttpx): Use `httpx.Client()`
authorOleg Broytman <phd@phdru.name>
Thu, 6 Mar 2025 17:09:58 +0000 (20:09 +0300)
committerOleg Broytman <phd@phdru.name>
Thu, 6 Mar 2025 17:09:58 +0000 (20:09 +0300)
Robots/bkmk_rhttpx.py

index b1451c6cf6c80ce76f889ddd031d7215e5eddf26..977342dbac42aaba3e67216cddadaa3b02295d90 100644 (file)
@@ -35,12 +35,11 @@ class robot_httpx(robot_base):
         else:
             proxy = None
 
-        error = r = None
         try:
-            r = httpx.get(url, headers=req_headers,
+            with httpx.Client(proxy=proxy, verify=False) as c:
+                r = c.get(url, headers=req_headers,
                           timeout=httpx.Timeout(self.timeout),
-                          follow_redirects=False, proxy=proxy,
-                          verify=False)
+                          follow_redirects=False)
         except (httpx.RequestError, socksio.ProtocolError) as e:
             error = str(e)
             return error, None, None, None