Skip to content

Commit 251ebd6

Browse files
author
Florian
committed
- changed the way headers are selected
- updated shared libraries
1 parent 48c7374 commit 251ebd6

11 files changed

+21
-13
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Example 1 - Preset:
1414
import tls_client
1515

1616
# You can also use the following as `client_identifier`:
17-
# Chrome --> chrome_103, chrome_104, chrome_105, chrome_106, chrome_107, chrome_108, chrome109, Chrome110
17+
# Chrome --> chrome_103, chrome_104, chrome_105, chrome_106, chrome_107, chrome_108, chrome109, Chrome110,
18+
# chrome111, chrome112
1819
# Firefox --> firefox_102, firefox_104, firefox108, Firefox110
1920
# Opera --> opera_89, opera_90
2021
# Safari --> safari_15_3, safari_15_6_1, safari_16_0
@@ -24,7 +25,7 @@ import tls_client
2425
# okhttp4_android_12, okhttp4_android_13
2526

2627
session = tls_client.Session(
27-
client_identifier="chrome110",
28+
client_identifier="chrome112",
2829
random_tls_extension_order=True
2930
)
3031

examples/example1 - preset.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import tls_client
22

33
# You can also use the following as `client_identifier`:
4-
# Chrome --> chrome_103, chrome_104, chrome_105, chrome_106, chrome_107, chrome_108, chrome109, Chrome110
4+
# Chrome --> chrome_103, chrome_104, chrome_105, chrome_106, chrome_107, chrome_108, chrome109, Chrome110,
5+
# chrome111, chrome112
56
# Firefox --> firefox_102, firefox_104, firefox108, Firefox110
67
# Opera --> opera_89, opera_90
78
# Safari --> safari_15_3, safari_15_6_1, safari_16_0
@@ -11,7 +12,7 @@
1112
# okhttp4_android_12, okhttp4_android_13
1213

1314
session = tls_client.Session(
14-
client_identifier="chrome109",
15+
client_identifier="chrome112",
1516
random_tls_extension_order=True
1617
)
1718

tls_client/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
__title__ = "tls_client"
88
__description__ = "Advanced Python HTTP Client."
9-
__version__ = "0.2"
9+
__version__ = "0.2.1"
1010
__author__ = "Florian Zager"
1111
__license__ = "MIT"
4.46 KB
Binary file not shown.
2.08 KB
Binary file not shown.
8.52 KB
Binary file not shown.
0 Bytes
Binary file not shown.
4.31 KB
Binary file not shown.
-24 Bytes
Binary file not shown.
8.8 KB
Binary file not shown.

tls_client/sessions.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -309,21 +309,27 @@ def execute_request(
309309
self.headers["Content-Type"] = content_type
310310

311311
# --- Headers --------------------------------------------------------------------------------------------------
312-
# merge headers of session and of the request
313-
if headers is not None:
314-
for header_key, header_value in headers.items():
315-
# check if all header keys and values are strings
316-
if type(header_key) is str and type(header_value) is str:
317-
self.headers[header_key] = header_value
318-
headers = self.headers
319-
else:
312+
if self.headers is None:
313+
headers = CaseInsensitiveDict(headers)
314+
elif headers is None:
320315
headers = self.headers
316+
else:
317+
merged_headers = CaseInsensitiveDict(self.headers)
318+
merged_headers.update(headers)
319+
320+
# Remove items, where the key or value is set to None.
321+
none_keys = [k for (k, v) in merged_headers.items() if v is None or k is None]
322+
for key in none_keys:
323+
del merged_headers[key]
324+
325+
headers = merged_headers
321326

322327
# --- Cookies --------------------------------------------------------------------------------------------------
323328
cookies = cookies or {}
324329
# Merge with session cookies
325330
cookies = merge_cookies(self.cookies, cookies)
326331
# turn cookie jar into dict
332+
# in the cookie value the " gets removed, because the fhttp library in golang doesn't accept the character
327333
request_cookies = [
328334
{'domain': c.domain, 'expires': c.expires, 'name': c.name, 'path': c.path, 'value': c.value.replace('"', "")}
329335
for c in cookies

0 commit comments

Comments
 (0)