- introduced cookies.has()
- only invoke cookies.get_all() when there are cookies stored
raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
elif domain == "":
raise ValueError("Parameter 'domain' is empty")
raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
elif domain == "":
raise ValueError("Parameter 'domain' is empty")
- elif not domain in _cookies:
raise Exception(f"domain='{domain}' has no cookies stored, maybe invoke store() first?")
# DEBUG: print(f"DEBUG: _cookies[{domain}]()={len(_cookies[domain])} - EXIT!")
return _cookies[domain]
raise Exception(f"domain='{domain}' has no cookies stored, maybe invoke store() first?")
# DEBUG: print(f"DEBUG: _cookies[{domain}]()={len(_cookies[domain])} - EXIT!")
return _cookies[domain]
+
+def has (domain: str) -> bool:
+ # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
+ if not isinstance(domain, str):
+ raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
+ elif domain == "":
+ raise ValueError("Parameter 'domain' is empty")
+
+ has_cookies = domain in _cookies
+
+ # DEBUG: print(f"DEBUG: has_cookies='{has_cookies}' - EXIT!")
+ return has_cookies
data=data,
headers={**api_headers, **headers},
timeout=(config.get("connection_timeout"), config.get("read_timeout")),
data=data,
headers={**api_headers, **headers},
timeout=(config.get("connection_timeout"), config.get("read_timeout")),
- cookies=cookies.get_all(domain)
+ cookies=cookies.get_all(domain) if cookies.has(domain) else {}
)
json_reply["json"] = json_from_response(response)
)
json_reply["json"] = json_from_response(response)
f"https://{domain}{path}",
headers={**api_headers, **headers},
timeout=timeout,
f"https://{domain}{path}",
headers={**api_headers, **headers},
timeout=timeout,
- cookies=cookies.get_all(domain)
+ cookies=cookies.get_all(domain) if cookies.has(domain) else {}
)
except exceptions as exception:
)
except exceptions as exception:
f"https://{domain}{path}",
headers=headers,
timeout=timeout,
f"https://{domain}{path}",
headers=headers,
timeout=timeout,
- cookies=cookies.get_all(domain)
+ cookies=cookies.get_all(domain) if cookies.has(domain) else {}
)
except exceptions as exception:
)
except exceptions as exception: