mirror of
https://github.com/RicterZ/nhentai.git
synced 2026-04-08 10:40:22 +02:00
History reset as part of DMCA compliance. The project has been refactored into a generic, site-agnostic download framework. Site-specific logic lives in separate plugin packages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# coding: utf-8
|
|
"""Generic async HTTP request helper (no site-specific headers injected here)."""
|
|
import httpx
|
|
import urllib3.exceptions
|
|
|
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
|
|
|
|
async def async_request(method, url, proxy=None, **kwargs):
|
|
"""
|
|
Thin async HTTP client wrapper.
|
|
|
|
Header injection (Cookie, User-Agent, Referer) is done by callers that
|
|
have access to site-specific configuration; this helper stays generic.
|
|
"""
|
|
from doujinshi_dl import constant
|
|
|
|
headers = kwargs.pop('headers', {})
|
|
|
|
if proxy is None:
|
|
proxy = constant.CONFIG.get('proxy', '')
|
|
|
|
if isinstance(proxy, str) and not proxy:
|
|
proxy = None
|
|
|
|
# Remove 'timeout' from kwargs to avoid duplicate keyword argument since
|
|
# httpx.AsyncClient accepts it as a constructor arg or request arg.
|
|
timeout = kwargs.pop('timeout', 30)
|
|
|
|
async with httpx.AsyncClient(headers=headers, verify=False, proxy=proxy,
|
|
timeout=timeout) as client:
|
|
response = await client.request(method, url, **kwargs)
|
|
|
|
return response
|