HttpCookie.Jar (http_cookie v0.7.0)
View SourceHTTP Cookie Jar
Handles storing cookies from response headers, preparing cookie headers for requests, etc.
Implemented according to RFC6265
Summary
Functions
Removes cookies which expired before the provided time from the jar.
Removes session cookies from the jar.
Formats the cookie for sending in a request header for the provided URL.
Gets all the cookies in the store which match the given request URL.
Creates a new empty cookie jar.
Stores the provided cookie in the jar.
Stores the provided cookies in the jar.
Processes the response header list for the given request URL. Parses set-cookie/set-cookie2 headers and stores valid cookies.
Types
Functions
@spec clear_expired_cookies( jar :: %HttpCookie.Jar{cookies: term(), opts: term()}, now :: DateTime.t() ) :: %HttpCookie.Jar{cookies: term(), opts: term()}
Removes cookies which expired before the provided time from the jar.
Uses the current time if no time is provided.
@spec clear_session_cookies(jar :: %HttpCookie.Jar{cookies: term(), opts: term()}) :: %HttpCookie.Jar{ cookies: term(), opts: term() }
Removes session cookies from the jar.
Cookies which don't have an explicit expiry time set are considered session cookies and they expire when a user session ends.
@spec get_cookie_header_value( jar :: %HttpCookie.Jar{cookies: term(), opts: term()}, request_url :: URI.t() ) :: {:ok, String.t(), %HttpCookie.Jar{cookies: term(), opts: term()}} | {:error, :no_matching_cookies}
Formats the cookie for sending in a request header for the provided URL.
@spec get_matching_cookies( jar :: %HttpCookie.Jar{cookies: term(), opts: term()}, request_url :: URI.t() ) :: {[HttpCookie.t()], %HttpCookie.Jar{cookies: term(), opts: term()}}
Gets all the cookies in the store which match the given request URL.
Creates a new empty cookie jar.
Options
:max_cookies
- maximum number of cookies stored, positive integer or :infinity, default: 5_000:max_cookies_per_domain
- maximum number of cookies stored per domain, positive integer or :infinity, default: 100:cookie_opts
- options passed to HttpCookie.from_cookie_string/3
@spec put_cookie( jar :: %HttpCookie.Jar{cookies: term(), opts: term()}, cookie :: HttpCookie.t(), opts :: list() ) :: %HttpCookie.Jar{cookies: term(), opts: term()}
Stores the provided cookie in the jar.
@spec put_cookies( jar :: %HttpCookie.Jar{cookies: term(), opts: term()}, cookies :: [HttpCookie.t()] ) :: %HttpCookie.Jar{cookies: term(), opts: term()}
Stores the provided cookies in the jar.
Processes the response header list for the given request URL. Parses set-cookie/set-cookie2 headers and stores valid cookies.