pub struct CookieJar { /* private fields */ }Expand description
In-memory and persistent cookie storage conforming to RFC 6265.
Implementations§
Source§impl CookieJar
impl CookieJar
Sourcepub fn store(&mut self, cookie: Cookie)
pub fn store(&mut self, cookie: Cookie)
Stores a cookie in the jar according to RFC 6265 §5.3 storage model.
Parses and stores a Set-Cookie header value in the context of an HTTP request URL.
Sourcepub fn process_response_headers(&mut self, headers: &Headers, request_url: &str)
pub fn process_response_headers(&mut self, headers: &Headers, request_url: &str)
Processes all Set-Cookie headers from an HTTP response.
Generates the Cookie request header string for an outgoing request URL.
Cookies are ordered per RFC 6265 §5.4: longer paths first, then earlier creation timestamps.
Sourcepub fn get(&self, name: &str, domain: &str, path: &str) -> Option<&Cookie>
pub fn get(&self, name: &str, domain: &str, path: &str) -> Option<&Cookie>
Retrieves a specific cookie by exact name, domain, and path.
Sourcepub fn remove(&mut self, name: &str, domain: &str, path: &str)
pub fn remove(&mut self, name: &str, domain: &str, path: &str)
Removes a specific cookie matching name, domain, and path.
Sourcepub fn clear_expired(&mut self)
pub fn clear_expired(&mut self)
Evicts all expired cookies from the jar.
Returns an iterator over all cookies currently stored in the jar.
Sourcepub fn from_json(json: &str) -> Result<Self, Error>
pub fn from_json(json: &str) -> Result<Self, Error>
Deserializes a cookie jar from a JSON string.
Sourcepub fn save_to_file(&self, path: &Path) -> Result<(), Error>
pub fn save_to_file(&self, path: &Path) -> Result<(), Error>
Persists all stored cookies to disk as a JSON file.
Sourcepub fn load_from_file(path: &Path) -> Result<Self, Error>
pub fn load_from_file(path: &Path) -> Result<Self, Error>
Loads persisted cookies from a JSON file on disk.