Skip to content

Commit

Permalink
- changed the way headers are selected
Browse files Browse the repository at this point in the history
- updated shared libraries
  • Loading branch information
Florian committed Apr 30, 2023
1 parent 48c7374 commit 251ebd6
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 13 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Example 1 - Preset:
import tls_client

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

session = tls_client.Session(
client_identifier="chrome110",
client_identifier="chrome112",
random_tls_extension_order=True
)

Expand Down
5 changes: 3 additions & 2 deletions examples/example1 - preset.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import tls_client

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

session = tls_client.Session(
client_identifier="chrome109",
client_identifier="chrome112",
random_tls_extension_order=True
)

Expand Down
2 changes: 1 addition & 1 deletion tls_client/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

__title__ = "tls_client"
__description__ = "Advanced Python HTTP Client."
__version__ = "0.2"
__version__ = "0.2.1"
__author__ = "Florian Zager"
__license__ = "MIT"
Binary file modified tls_client/dependencies/tls-client-32.dll
Binary file not shown.
Binary file modified tls_client/dependencies/tls-client-64.dll
Binary file not shown.
Binary file modified tls_client/dependencies/tls-client-amd64.so
Binary file not shown.
Binary file modified tls_client/dependencies/tls-client-arm64.dylib
Binary file not shown.
Binary file modified tls_client/dependencies/tls-client-arm64.so
Binary file not shown.
Binary file modified tls_client/dependencies/tls-client-x86.dylib
Binary file not shown.
Binary file modified tls_client/dependencies/tls-client-x86.so
Binary file not shown.
22 changes: 14 additions & 8 deletions tls_client/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,27 @@ def execute_request(
self.headers["Content-Type"] = content_type

# --- Headers --------------------------------------------------------------------------------------------------
# merge headers of session and of the request
if headers is not None:
for header_key, header_value in headers.items():
# check if all header keys and values are strings
if type(header_key) is str and type(header_value) is str:
self.headers[header_key] = header_value
headers = self.headers
else:
if self.headers is None:
headers = CaseInsensitiveDict(headers)
elif headers is None:
headers = self.headers
else:
merged_headers = CaseInsensitiveDict(self.headers)
merged_headers.update(headers)

# Remove items, where the key or value is set to None.
none_keys = [k for (k, v) in merged_headers.items() if v is None or k is None]
for key in none_keys:
del merged_headers[key]

headers = merged_headers

# --- Cookies --------------------------------------------------------------------------------------------------
cookies = cookies or {}
# Merge with session cookies
cookies = merge_cookies(self.cookies, cookies)
# turn cookie jar into dict
# in the cookie value the " gets removed, because the fhttp library in golang doesn't accept the character
request_cookies = [
{'domain': c.domain, 'expires': c.expires, 'name': c.name, 'path': c.path, 'value': c.value.replace('"', "")}
for c in cookies
Expand Down

0 comments on commit 251ebd6

Please sign in to comment.