HttpCookie (http_cookie v0.7.0)
View SourceHTTP Cookie struct with parsing and related logic.
Implemented according to RFC6265
Summary
Functions
Checks if the cookie has expired.
Creates an HttpCookie from a Set-Cookie
header value.
Checks if the cookie matches the provided request url.
Formats the cookie for sending in a "Cookie" header.
Updates the cookie last access time.
Types
@type t() :: %HttpCookie{ creation_time: DateTime.t(), domain: binary(), expiry_time: DateTime.t(), host_only?: boolean(), http_only?: boolean(), last_access_time: DateTime.t(), name: binary(), path: binary(), persistent?: boolean(), secure_only?: boolean(), value: binary() }
Functions
@spec expired?(cookie :: t(), now :: DateTime.t()) :: boolean()
Checks if the cookie has expired.
Uses the current time if no time is provided.
@spec from_cookie_string(str :: String.t(), request_url :: URI.t(), opts :: keyword()) :: {:ok, t()} | {:error, atom()}
Creates an HttpCookie from a Set-Cookie
header value.
Options
:max_cookie_size
- maximum size of cookie string in bytes, positive integer or :infinity, default: 8_192:reject_public_suffixes
- controls whether to reject public suffixes to guard against "supercookies", defaults to true
Checks if the cookie matches the provided request url.
The check is done as specified in RFC 6265.
Formats the cookie for sending in a "Cookie" header.
@spec update_last_access_time(cookie :: t(), DateTime.t()) :: t()
Updates the cookie last access time.
Uses the current time if no time is provided.