first commit

This commit is contained in:
2025-10-26 13:38:37 +03:00
commit 15990c82df
11 changed files with 492 additions and 0 deletions

62
src/aiohttpx/client.py Normal file
View File

@ -0,0 +1,62 @@
from collections.abc import Callable, Mapping
from logging import getLogger
from ssl import SSLContext
from typing import Any
from httpx import URL, Limits
from httpx import AsyncClient as AsyncHTTPXClient
from httpx import _config as c # type: ignore
from httpx import _types as t # type: ignore
from aiohttpx.transports.cache import AsyncCacheTransport
class AioHTTPXClient(AsyncHTTPXClient):
def __init__(
self,
*,
auth: t.AuthTypes | None = None,
params: t.QueryParamTypes | None = None,
headers: t.HeaderTypes | None = None,
cookies: t.CookieTypes | None = None,
verify: SSLContext | str | bool = True,
cert: t.CertTypes | None = None,
proxy: t.ProxyTypes | None = None,
timeout: t.TimeoutTypes = c.DEFAULT_TIMEOUT_CONFIG,
follow_redirects: bool = False,
limits: Limits = c.DEFAULT_LIMITS,
max_redirects: int = c.DEFAULT_MAX_REDIRECTS,
event_hooks: Mapping[str, list[Callable[..., Any]]] | None = None,
base_url: URL | str = '',
trust_env: bool = True,
default_encoding: str | Callable[[bytes], str] = 'utf-8',
redis_url: str | None = None,
key: str | None = None,
limit: int | None = None,
):
super().__init__(
auth=auth,
params=params,
headers=headers,
cookies=cookies,
verify=verify,
cert=cert,
http1=True,
http2=False,
proxy=proxy,
mounts=None,
timeout=timeout,
follow_redirects=follow_redirects,
limits=limits,
max_redirects=max_redirects,
event_hooks=event_hooks,
base_url=base_url,
transport=AsyncCacheTransport(redis_url, key, limit),
trust_env=trust_env,
default_encoding=default_encoding,
)
self.logger = getLogger(__name__)
__all__ = ['AioHTTPXClient']