Skip to content
Discussion options

You must be logged in to vote

This is actually intentional and follows standard Python HTTP networking conventions (such as urllib.request.HTTPCookieProcessor(cookiejar)).

Why CookieJar is aliased rather than cloned

Passing an explicit http.cookiejar.CookieJar instance (or subclass) is the primary mechanism in Python for stateful persistence and custom policy:

  1. Persistent Jars (MozillaCookieJar / LWPCookieJar):
    When users pass a file-backed jar:

    from http.cookiejar import MozillaCookieJar
    import httpx
    
    jar = MozillaCookieJar("cookies.txt")
    with httpx.Client(cookies=jar) as client:
        client.get("https://example.com/login")
    jar.save()  # <--- Expects cookies extracted during the session to be present

    If httpx.Cookies

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by tritsystem
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants