mirror of
https://github.com/RicterZ/nhentai.git
synced 2026-04-08 18:50:21 +02:00
Initial commit: doujinshi-dl generic plugin framework
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>
This commit is contained in:
34
doujinshi_dl/core/utils/http.py
Normal file
34
doujinshi_dl/core/utils/http.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user