Skip to content

Give control over cookies #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions tls_client/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ctypes
import uuid


class Session:

def __init__(
Expand All @@ -39,7 +38,7 @@ def __init__(
debug: Optional = False,
certificate_pinning: Optional[Dict[str, List[str]]] = None,
) -> None:
self._session_id = str(uuid.uuid4())
self._session_id = 1
# --- Standard Settings ----------------------------------------------------------------------------------------

# Case-insensitive dictionary of headers, send on each request
Expand Down Expand Up @@ -315,6 +314,8 @@ def execute_request(
timeout_seconds: Optional[int] = None,
proxy: Optional[dict] = None # Optional[dict[str, str]]
) -> Response:

self._session_id += 1
# --- URL ------------------------------------------------------------------------------------------------------
# Prepare URL - add params to url
if params is not None:
Expand Down Expand Up @@ -360,10 +361,13 @@ def execute_request(
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
]
if 'cookie' in headers or 'Cookie' in headers:
request_cookies = []
else:
request_cookies = [
{'domain': c.domain, 'expires': c.expires, 'name': c.name, 'path': c.path, 'value': c.value.replace('"', "")}
for c in cookies
]

# --- Proxy ----------------------------------------------------------------------------------------------------
proxy = proxy or self.proxies
Expand All @@ -388,7 +392,7 @@ def execute_request(
# --- Request --------------------------------------------------------------------------------------------------
is_byte_request = isinstance(request_body, (bytes, bytearray))
request_payload = {
"sessionId": self._session_id,
"sessionId": str(self._session_id),
"followRedirects": allow_redirects,
"forceHttp1": self.force_http1,
"withDebug": self.debug,
Expand Down