pub struct CookieJar { /* private fields */ }
cookies
only.Expand description
Provides automatic cookie session management using an in-memory cookie store.
Cookie jars are designed to be shareable across many concurrent requests, so cloning the jar simply returns a new reference to the jar instead of doing a deep clone.
This cookie jar implementation seeks to conform to the rules for client state management as described in RFC 6265.
Domain isolation
Cookies are isolated from each other based on the domain and path they are received from. As such, most methods require you to specify a URI, since unrelated websites can have cookies with the same name without conflict.
Implementations
sourceimpl CookieJar
impl CookieJar
sourcepub fn get_by_name(&self, uri: &Uri, cookie_name: &str) -> Option<Cookie>
pub fn get_by_name(&self, uri: &Uri, cookie_name: &str) -> Option<Cookie>
Get a cookie by name for the given URI.
sourcepub fn get_for_uri(&self, uri: &Uri) -> impl IntoIterator<Item = Cookie>
pub fn get_for_uri(&self, uri: &Uri) -> impl IntoIterator<Item = Cookie>
Get a copy of all the cookies in the jar that match the given URI.
The returned collection contains a copy of all the cookies matching the URI at the time this function was called. The collection is not a “live” view into the cookie jar; concurrent changes made to the jar (cookies inserted or removed) will not be reflected in the collection.
sourcepub fn set(
&self,
cookie: Cookie,
request_uri: &Uri
) -> Result<Option<Cookie>, CookieRejectedError>
pub fn set(
&self,
cookie: Cookie,
request_uri: &Uri
) -> Result<Option<Cookie>, CookieRejectedError>
Set a cookie for the given absolute request URI.
If the cookie was set successfully, returns the cookie that previously existed for the given domain, path, and cookie name, if any.
If unsuccessful, returns a CookieRejectedError
which can be used to get back the
attempted cookie.