notify-tls-client 0.1.6__py3-none-any.whl → 2.0.0__py3-none-any.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.
Files changed (32) hide show
  1. notify_tls_client/__init__.py +2 -2
  2. notify_tls_client/config/__init__.py +18 -0
  3. notify_tls_client/config/client_config.py +76 -0
  4. notify_tls_client/config/client_configuration.py +237 -0
  5. notify_tls_client/config/recovery_config.py +66 -0
  6. notify_tls_client/config/rotation_config.py +56 -0
  7. notify_tls_client/core/client/__init__.py +1 -6
  8. notify_tls_client/core/client/decorators.py +200 -90
  9. notify_tls_client/core/client_identifiers_manager.py +44 -0
  10. notify_tls_client/core/notifytlsclient.py +271 -146
  11. notify_tls_client/core/proxiesmanager/__init__.py +1 -1
  12. notify_tls_client/core/proxiesmanager/proxiesmanager.py +79 -67
  13. notify_tls_client/core/proxiesmanager/proxiesmanagerloader.py +33 -33
  14. notify_tls_client/tls_client/__init__.py +14 -14
  15. notify_tls_client/tls_client/__version__.py +10 -10
  16. notify_tls_client/tls_client/cffi.py +40 -62
  17. notify_tls_client/tls_client/cookies.py +456 -456
  18. notify_tls_client/tls_client/dependencies/{tls-client-xgo-1.11.0-darwin-arm64.dylib → tls-client-darwin-amd64-1.12.0.dylib} +0 -0
  19. notify_tls_client/tls_client/dependencies/tls-client-linux-arm64-1.12.0.so +0 -0
  20. notify_tls_client/tls_client/dependencies/{tls-client-xgo-1.11.0-linux-amd64.so → tls-client-linux-ubuntu-amd64-1.12.0.so} +0 -0
  21. notify_tls_client/tls_client/dependencies/{tls-client-windows-1.11.0-64.dll → tls-client-windows-64-1.12.0.dll} +0 -0
  22. notify_tls_client/tls_client/exceptions.py +2 -2
  23. notify_tls_client/tls_client/response.py +84 -78
  24. notify_tls_client/tls_client/sessions.py +524 -513
  25. notify_tls_client/tls_client/settings.py +69 -69
  26. notify_tls_client/tls_client/structures.py +74 -74
  27. notify_tls_client-2.0.0.dist-info/METADATA +38 -0
  28. notify_tls_client-2.0.0.dist-info/RECORD +32 -0
  29. {notify_tls_client-0.1.6.dist-info → notify_tls_client-2.0.0.dist-info}/WHEEL +1 -1
  30. notify_tls_client-0.1.6.dist-info/METADATA +0 -16
  31. notify_tls_client-0.1.6.dist-info/RECORD +0 -25
  32. {notify_tls_client-0.1.6.dist-info → notify_tls_client-2.0.0.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,3 @@
1
-
2
- class TLSClientExeption(IOError):
1
+
2
+ class TLSClientExeption(IOError):
3
3
  """General error with the TLS client"""
@@ -1,78 +1,84 @@
1
- from .cookies import cookiejar_from_dict, RequestsCookieJar
2
- from .structures import CaseInsensitiveDict
3
-
4
- from typing import Union
5
- import json
6
-
7
-
8
- class Response:
9
- """object, which contains the response to an HTTP request."""
10
-
11
- def __init__(self):
12
-
13
- # Reference of URL the response is coming from (especially useful with redirects)
14
- self.url = None
15
-
16
- # Integer Code of responded HTTP Status, e.g. 404 or 200.
17
- self.status_code = None
18
-
19
- # String of responded HTTP Body.
20
- self.text = None
21
-
22
- # Case-insensitive Dictionary of Response Headers.
23
- self.headers = CaseInsensitiveDict()
24
-
25
- # A CookieJar of Cookies the server sent back.
26
- self.cookies = cookiejar_from_dict({})
27
-
28
- self._content = False
29
-
30
- def __enter__(self):
31
- return self
32
-
33
- def __repr__(self):
34
- return f"<Response [{self.status_code}]>"
35
-
36
- def json(self, **kwargs):
37
- """parse response body to json (dict/list)"""
38
- return json.loads(self.text, **kwargs)
39
-
40
- @property
41
- def content(self):
42
- """Content of the response, in bytes."""
43
-
44
- if self._content is False:
45
- if self._content_consumed:
46
- raise RuntimeError("The content for this response was already consumed")
47
-
48
- if self.status_code == 0:
49
- self._content = None
50
- else:
51
- self._content = b"".join(self.iter_content(10 * 1024)) or b""
52
- self._content_consumed = True
53
- return self._content
54
-
55
-
56
- def build_response(res: Union[dict, list], res_cookies: RequestsCookieJar) -> Response:
57
- """Builds a Response object """
58
- response = Response()
59
- # Add target / url
60
- response.url = res["target"]
61
- # Add status code
62
- response.status_code = res["status"]
63
- # Add headers
64
- response_headers = {}
65
- if res["headers"] is not None:
66
- for header_key, header_value in res["headers"].items():
67
- if len(header_value) == 1:
68
- response_headers[header_key] = header_value[0]
69
- else:
70
- response_headers[header_key] = header_value
71
- response.headers = response_headers
72
- # Add cookies
73
- response.cookies = res_cookies
74
- # Add response body
75
- response.text = res["body"]
76
- # Add response content (bytes)
77
- response._content = res["body"].encode()
78
- return response
1
+ from orjson import orjson
2
+
3
+ from .cookies import cookiejar_from_dict, RequestsCookieJar
4
+ from .structures import CaseInsensitiveDict
5
+
6
+ from typing import Union
7
+ import json
8
+
9
+
10
+ class Response:
11
+ """object, which contains the response to an HTTP request."""
12
+
13
+ def __init__(self):
14
+
15
+ # Reference of URL the response is coming from (especially useful with redirects)
16
+ self.elapsed = None
17
+ self.url = None
18
+
19
+ # Integer Code of responded HTTP Status, e.g. 404 or 200.
20
+ self.status_code = None
21
+
22
+ # String of responded HTTP Body.
23
+ self.text = None
24
+
25
+ # Case-insensitive Dictionary of Response Headers.
26
+ self.headers = CaseInsensitiveDict()
27
+
28
+ # A CookieJar of Cookies the server sent back.
29
+ self.cookies = cookiejar_from_dict({})
30
+
31
+ self._content = False
32
+ self._content_consumed = False
33
+
34
+ def __enter__(self):
35
+ return self
36
+
37
+ def __repr__(self):
38
+ return f"<Response [{self.status_code}]>"
39
+
40
+ def json(self, **kwargs):
41
+ """parse response body to json (dict/list)"""
42
+ return orjson.loads(self.text, **kwargs)
43
+
44
+ @property
45
+ def content(self):
46
+ """Content of the response, in bytes."""
47
+
48
+ if self._content is False:
49
+ if self._content_consumed:
50
+ raise RuntimeError("The content for this response was already consumed")
51
+
52
+ if self.status_code == 0:
53
+ self._content = None
54
+ else:
55
+ self._content = b"".join(self.iter_content(10 * 1024)) or b""
56
+ self._content_consumed = True
57
+ return self._content
58
+
59
+
60
+ def build_response(res: Union[dict, list], res_cookies: RequestsCookieJar) -> Response:
61
+ """Builds a Response object """
62
+ response = Response()
63
+ # Add target / url
64
+ response.url = res.get("target", None)
65
+ # Add status code
66
+ response.status_code = res.get("status", 0)
67
+
68
+ response.elapsed = res.get("elapsed", None)
69
+ # Add headers
70
+ response_headers = {}
71
+ if res.get('headers', None) is not None:
72
+ for header_key, header_value in res["headers"].items():
73
+ if len(header_value) == 1:
74
+ response_headers[header_key] = header_value[0]
75
+ else:
76
+ response_headers[header_key] = header_value
77
+ response.headers = response_headers
78
+ # Add cookies
79
+ response.cookies = None
80
+ # Add response body
81
+ response.text = res["body"]
82
+ # Add response content (bytes)
83
+ response._content = res["body"].encode()
84
+ return response