Skip to content

Support Sequence[Tuple[str, str]] type when setting cookies. #1209

Closed

Description

@lovelydinosaur

For consistency, we should support styles like: cookies=[('name', 'value')].

We allow either dicts or lists-of-tuples for each of data, files, params & headers, so it makes sense for us to do it here too.

Activity

  1. lovelydinosaur commented on Aug 21, 2020

    @lovelydinosaur
    MemberAuthor

    We'd want to adjust the __init__ to handle that case properly...

    if cookies is None or isinstance(cookies, dict):

    And adjust the type signature...

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

    Plus add a test case for it in here... https://github.com/encode/httpx/blob/master/tests/models/test_cookies.py
    I guess use something like this...

    cookies = httpx.Cookies([("key1", "value1"), ("key2", "value2")])
    # followed by some appropriate assertions, similar to those in `test_cookies`.

    Ideally do this in two commits - first add the (failing) test case, and then add the fixes.

  2. lovelydinosaur commented on Aug 25, 2020

    @lovelydinosaur
    MemberAuthor

    Closed via #1211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions