Commit 1f35f42

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-12-07 04:32:11
chore(ssl): add SSL verification option to `hx_req` function
1 parent 437fbcd
Changed files (1)
src/networking.py
@@ -50,6 +50,7 @@ async def hx_req(
     timeout: int = REQUEST_TIMEOUT,  # noqa: ASYNC109
     retry: int = 0,
     max_retry: int = 2,
+    verify: bool = True,
     silent: bool = False,
     mobile: bool = False,
     rformat: Literal["json", "text", "content"] = "json",
@@ -73,6 +74,7 @@ async def hx_req(
         check_kv (dict, optional): The key-value pairs to check in the response.
         timeout (int, optional): The timeout for the request.
         retry (int, optional): The number of retries for the request.
+        verify (bool, optional): Whether to verify the SSL certificate.
         silent (bool, optional): Whether to suppress the logs.
         mobile (bool, optional): Whether to use mobile headers.
         rformat (str, optional): The format of the response.
@@ -89,9 +91,17 @@ async def hx_req(
         transport = AsyncCurlTransport(proxy=proxy, impersonate="safari_ios" if mobile else "chrome", default_headers=True, curl_options={CurlOpt.FRESH_CONNECT: True})
 
     if silent:
-        client = AsyncClient(http2=True, proxy=proxy, transport=transport, follow_redirects=follow_redirects, timeout=timeout)
+        client = AsyncClient(http2=True, proxy=proxy, transport=transport, follow_redirects=follow_redirects, timeout=timeout, verify=verify)
     else:
-        client = AsyncClient(http2=True, proxy=proxy, transport=transport, follow_redirects=follow_redirects, timeout=timeout, event_hooks={"request": [log_req], "response": [log_resp]})
+        client = AsyncClient(
+            http2=True,
+            proxy=proxy,
+            transport=transport,
+            follow_redirects=follow_redirects,
+            timeout=timeout,
+            verify=verify,
+            event_hooks={"request": [log_req], "response": [log_resp]},
+        )
 
     if method not in ["GET", "POST", "PUT", "DELETE"]:
         error = f"Invalid method: {method}"