This commit is contained in:
monosans
2024-02-07 10:25:01 +03:00
parent 9026cf9fb4
commit 35518b67e9
2 changed files with 8 additions and 11 deletions
+1 -2
View File
@@ -2,10 +2,9 @@ from __future__ import annotations
import os as _os
from .typing_compat import Any as _Any
# Monkeypatch os.link to make aiofiles work on Termux
if not hasattr(_os, "link"):
from .typing_compat import Any as _Any
def _link(*args: _Any, **kwargs: _Any) -> None: # noqa: ARG001
raise RuntimeError
+7 -9
View File
@@ -9,6 +9,11 @@ from aiohttp import ClientResponse, DummyCookieJar, hdrs
from .utils import bytes_decode
HEADERS: MappingProxyType[str, str] = MappingProxyType({
hdrs.USER_AGENT: (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" # noqa: E501
)
})
SSL_CONTEXT = ssl.create_default_context(cafile=certifi.where())
@@ -16,11 +21,8 @@ class NoCharsetHeaderError(Exception):
pass
HEADERS: MappingProxyType[str, str] = MappingProxyType({
hdrs.USER_AGENT: (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" # noqa: E501
)
})
def fallback_charset_resolver(r: ClientResponse, b: bytes) -> str: # noqa: ARG001
raise NoCharsetHeaderError
@lru_cache(None)
@@ -33,7 +35,3 @@ def get_response_text(*, response: ClientResponse, content: bytes) -> str:
return content.decode(response.get_encoding())
except (NoCharsetHeaderError, UnicodeDecodeError):
return bytes_decode(content)
def fallback_charset_resolver(r: ClientResponse, b: bytes) -> str: # noqa: ARG001
raise NoCharsetHeaderError