Skip to content

yggdrasil.http_.cookies

cookies

Lightweight cookie jar used by :class:HTTPSession browser-style methods.

Cookies

Cookies(initial: Optional[Mapping[str, str]] = None)

Mapping-like cookie jar with Cookie / Set-Cookie plumbing.

Stored as name -> value pairs without attribute parsing (Path, Expires, HttpOnly, Secure, Domain are ignored). That matches the rest of the browser-mode helpers, which intentionally stay close to a "browser-as-a-string-bag" model rather than reimplementing :mod:http.cookiejar semantics.

to_header

to_header() -> str

Serialize the jar into a Cookie request-header value.

Returns an empty string when the jar is empty so callers can if header: skip emitting the header entirely.

parse_set_cookie(header: str) -> tuple[str, str]

Parse a single Set-Cookie header value into (name, value).

Attribute pairs after the first ; are dropped on purpose — see the class docstring.

update_from_set_cookie(raw: str) -> None

Merge a raw Set-Cookie header value into the jar.

urllib3 collapses multiple Set-Cookie values with a comma, so we split and best-effort parse each piece.

update_from_response

update_from_response(response: 'HTTPResponse') -> None

Pull cookies out of response's Set-Cookie header(s).