Skip to content

Commit

Permalink
Made cookies constructable from a list of tuples (#1209)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdeler committed Aug 21, 2020
1 parent 4dae142 commit e4de55b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions httpx/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,10 @@ def __init__(self, cookies: CookieTypes = None) -> None:
if isinstance(cookies, dict):
for key, value in cookies.items():
self.set(key, value)
elif isinstance(cookies, list):
self.jar = CookieJar()
for key, value in cookies:
self.set(key, value)
elif isinstance(cookies, Cookies):
self.jar = CookieJar()
for cookie in cookies.jar:
Expand Down
2 changes: 1 addition & 1 deletion httpx/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
Sequence[Tuple[bytes, bytes]],
]

CookieTypes = Union["Cookies", CookieJar, Dict[str, str]]
CookieTypes = Union["Cookies", CookieJar, Dict[str, str], List[Tuple[str, str]]]

CertTypes = Union[str, Tuple[str, str], Tuple[str, str, str]]
VerifyTypes = Union[str, bool, ssl.SSLContext]
Expand Down

0 comments on commit e4de55b

Please sign in to comment.