http-tls 0.2.1__cp38-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
http_tls/__init__.py ADDED
@@ -0,0 +1,79 @@
1
+ """http_tls: High-performance Rust & TLS Fingerprint Impersonating HTTP client for Python.
2
+
3
+ 100% Drop-in replacement for both `requests` and `curl_cffi.requests`:
4
+ import http_tls as requests
5
+ from http_tls import requests
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import sys
11
+ from http_tls import exceptions, requests, status_codes, structures
12
+ from http_tls.exceptions import (
13
+ ConnectTimeout,
14
+ ConnectionError,
15
+ HTTPError,
16
+ ReadTimeout,
17
+ RequestException,
18
+ SSLError,
19
+ Timeout,
20
+ TooManyRedirects,
21
+ )
22
+ from http_tls.requests import (
23
+ AsyncSession,
24
+ BrowserType,
25
+ Response,
26
+ Session,
27
+ delete,
28
+ get,
29
+ head,
30
+ options,
31
+ patch,
32
+ post,
33
+ put,
34
+ request,
35
+ supported_presets,
36
+ )
37
+ from http_tls.status_codes import codes
38
+ from http_tls.structures import CaseInsensitiveDict
39
+
40
+ # Package version
41
+ try:
42
+ from http_tls._core import __version__
43
+ except ImportError:
44
+ __version__ = "0.2.1"
45
+
46
+ # Register module alias in sys.modules so `import http_tls.requests as requests` works
47
+ sys.modules["http_tls.requests"] = requests
48
+
49
+ __all__ = [
50
+ # Requests compatibility
51
+ "requests",
52
+ "codes",
53
+ "exceptions",
54
+ "structures",
55
+ "CaseInsensitiveDict",
56
+ "RequestException",
57
+ "HTTPError",
58
+ "ConnectionError",
59
+ "Timeout",
60
+ "ConnectTimeout",
61
+ "ReadTimeout",
62
+ "SSLError",
63
+ "TooManyRedirects",
64
+ # Main classes & funcs
65
+ "Response",
66
+ "Session",
67
+ "AsyncSession",
68
+ "BrowserType",
69
+ "request",
70
+ "get",
71
+ "post",
72
+ "put",
73
+ "delete",
74
+ "patch",
75
+ "head",
76
+ "options",
77
+ "supported_presets",
78
+ "__version__",
79
+ ]
http_tls/__init__.pyi ADDED
@@ -0,0 +1,86 @@
1
+ from typing import Any, Dict, List, Optional, Union
2
+
3
+ __version__: str
4
+
5
+ def supported_presets() -> List[str]: ...
6
+
7
+ class Response:
8
+ status_code: int
9
+ headers: Dict[str, str]
10
+ url: str
11
+ content: bytes
12
+ text: str
13
+ encoding: str
14
+ elapsed: float
15
+ cookies: Dict[str, str]
16
+
17
+ def json(self) -> Any: ...
18
+ def ok(self) -> bool: ...
19
+
20
+ class Session:
21
+ def __init__(
22
+ self,
23
+ impersonate: str = "chrome_152",
24
+ timeout: float = 30.0,
25
+ follow_redirects: bool = True,
26
+ max_redirects: int = 10,
27
+ verify_ssl: bool = True,
28
+ proxy: Optional[str] = None,
29
+ headers: Optional[Dict[str, str]] = None,
30
+ ) -> None: ...
31
+ @property
32
+ def impersonate(self) -> str: ...
33
+ def request(
34
+ self,
35
+ method: str,
36
+ url: str,
37
+ params: Optional[Dict[str, str]] = None,
38
+ headers: Optional[Dict[str, str]] = None,
39
+ cookies: Optional[Dict[str, str]] = None,
40
+ data: Optional[Union[bytes, str]] = None,
41
+ json: Optional[Any] = None,
42
+ timeout: Optional[float] = None,
43
+ proxy: Optional[str] = None,
44
+ ) -> Response: ...
45
+ def get(self, url: str, **kwargs: Any) -> Response: ...
46
+ def post(self, url: str, **kwargs: Any) -> Response: ...
47
+ def put(self, url: str, **kwargs: Any) -> Response: ...
48
+ def delete(self, url: str, **kwargs: Any) -> Response: ...
49
+ def patch(self, url: str, **kwargs: Any) -> Response: ...
50
+ def head(self, url: str, **kwargs: Any) -> Response: ...
51
+ def options(self, url: str, **kwargs: Any) -> Response: ...
52
+ def __enter__(self) -> Session: ...
53
+ def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: ...
54
+
55
+ class AsyncSession:
56
+ def __init__(
57
+ self,
58
+ impersonate: str = "chrome_152",
59
+ timeout: float = 30.0,
60
+ follow_redirects: bool = True,
61
+ max_redirects: int = 10,
62
+ verify_ssl: bool = True,
63
+ proxy: Optional[str] = None,
64
+ headers: Optional[Dict[str, str]] = None,
65
+ ) -> None: ...
66
+ @property
67
+ def impersonate(self) -> str: ...
68
+ async def request(self, method: str, url: str, **kwargs: Any) -> Response: ...
69
+ async def get(self, url: str, **kwargs: Any) -> Response: ...
70
+ async def post(self, url: str, **kwargs: Any) -> Response: ...
71
+ async def put(self, url: str, **kwargs: Any) -> Response: ...
72
+ async def delete(self, url: str, **kwargs: Any) -> Response: ...
73
+ async def patch(self, url: str, **kwargs: Any) -> Response: ...
74
+ async def head(self, url: str, **kwargs: Any) -> Response: ...
75
+ async def options(self, url: str, **kwargs: Any) -> Response: ...
76
+ async def __aenter__(self) -> AsyncSession: ...
77
+ async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: ...
78
+
79
+ def request(method: str, url: str, impersonate: str = "chrome_152", **kwargs: Any) -> Response: ...
80
+ def get(url: str, impersonate: str = "chrome_152", **kwargs: Any) -> Response: ...
81
+ def post(url: str, impersonate: str = "chrome_152", **kwargs: Any) -> Response: ...
82
+ def put(url: str, impersonate: str = "chrome_152", **kwargs: Any) -> Response: ...
83
+ def delete(url: str, impersonate: str = "chrome_152", **kwargs: Any) -> Response: ...
84
+ def patch(url: str, impersonate: str = "chrome_152", **kwargs: Any) -> Response: ...
85
+ def head(url: str, impersonate: str = "chrome_152", **kwargs: Any) -> Response: ...
86
+ def options(url: str, impersonate: str = "chrome_152", **kwargs: Any) -> Response: ...
http_tls/_core.pyd ADDED
Binary file
http_tls/exceptions.py ADDED
@@ -0,0 +1,27 @@
1
+ """Exceptions compatible with requests.exceptions."""
2
+
3
+ class RequestException(IOError):
4
+ def __init__(self, *args, **kwargs):
5
+ self.response = kwargs.pop("response", None)
6
+ super().__init__(*args, **kwargs)
7
+
8
+ class HTTPError(RequestException):
9
+ """An HTTP error occurred."""
10
+
11
+ class ConnectionError(RequestException):
12
+ """A Connection error occurred."""
13
+
14
+ class Timeout(RequestException):
15
+ """The request timed out."""
16
+
17
+ class ConnectTimeout(Timeout, ConnectionError):
18
+ """The request timed out while trying to connect to the remote server."""
19
+
20
+ class ReadTimeout(Timeout):
21
+ """The server did not send any data in the allotted amount of time."""
22
+
23
+ class SSLError(ConnectionError):
24
+ """An SSL error occurred."""
25
+
26
+ class TooManyRedirects(RequestException):
27
+ """Too many redirects."""
http_tls/py.typed ADDED
@@ -0,0 +1 @@
1
+