livery_client_cookie (livery v0.4.4)

View Source

Client layer: a cookie jar (RFC 6265, client side).

Before each request it picks the stored cookies that match the target (host, path, secure) and merges them into one Cookie header, keeping any Cookie the caller already set. After the response it parses every Set-Cookie header and updates the jar: a new cookie replaces the one under the same (domain, path, name) key, and an expired one (a past Expires, or Max-Age <= 0) deletes it. Add it with livery_client:cookie_jar/0,1.

The jar keeps no cookies of its own; it reads and writes them through a livery_client_cookie_store (default livery_client_cookie_store_ets), an in-memory per-jar store shared across the request processes that run the client.

This is a subset: no public suffix list, no third-party-cookie policy, no persistence. SameSite is parsed but not enforced.

Summary

Functions

Build a jar with the default ETS store and cookie cap.

Build a jar. Opts: max_cookies (total cap before the oldest are evicted, default 3000), store (a livery_client_cookie_store callback module, default livery_client_cookie_store_ets). Any other keys are passed through to the store's init/1.

Types

state()

-opaque state()

Functions

call(Req, Next, State)

-spec call(livery_client:request(), livery_client:next(), state()) ->
              {ok, livery_client:response()} | {error, term()}.

jar()

-spec jar() -> state().

Build a jar with the default ETS store and cookie cap.

jar(Opts)

-spec jar(map()) -> state().

Build a jar. Opts: max_cookies (total cap before the oldest are evicted, default 3000), store (a livery_client_cookie_store callback module, default livery_client_cookie_store_ets). Any other keys are passed through to the store's init/1.