Struct hyper::header::CookieJar [−][src]
pub struct CookieJar<'a> { /* fields omitted */ }
A jar of cookies for managing a session
Example
use cookie::{Cookie, CookieJar}; let c = CookieJar::new(b"f8f9eaf1ecdedff5e5b749c58115441e"); // Add a cookie to this jar c.add(Cookie::new("key".to_string(), "value".to_string())); // Remove the added cookie c.remove("key");
Methods
impl<'a> CookieJar<'a>
[src]
impl<'a> CookieJar<'a>
pub fn new(key: &[u8]) -> CookieJar<'static>
[src]
pub fn new(key: &[u8]) -> CookieJar<'static>
Creates a new empty cookie jar with the given signing key.
The given key is used to sign cookies in the signed cookie jar.
pub fn add_original(&mut self, cookie: Cookie)
[src]
pub fn add_original(&mut self, cookie: Cookie)
Adds an original cookie from a request.
This method only works on the root cookie jar and is not intended for use during the lifetime of a request, it is intended to initialize a cookie jar from an incoming request.
pub fn add(&self, cookie: Cookie)
[src]
pub fn add(&self, cookie: Cookie)
Adds a new cookie to this cookie jar.
If this jar is a child cookie jar, this will walk up the chain of borrowed jars, modifying the cookie as it goes along.
pub fn remove(&self, cookie: &str)
[src]
pub fn remove(&self, cookie: &str)
Removes a cookie from this cookie jar.
pub fn find(&self, name: &str) -> Option<Cookie>
[src]
pub fn find(&self, name: &str) -> Option<Cookie>
Finds a cookie inside of this cookie jar.
The cookie is subject to modification by any of the child cookie jars that are currently borrowed. A copy of the cookie is returned.
pub fn signed(&'b self) -> CookieJar<'b>
[src]
pub fn signed(&'b self) -> CookieJar<'b>
Creates a child signed cookie jar.
All cookies read from the child jar will require a valid signature and all cookies written will be signed automatically.
Example
let c = CookieJar::new(b"f8f9eaf1ecdedff5e5b749c58115441e"); // Add a signed cookie to the jar c.signed().add(Cookie::new("key".to_string(), "value".to_string())); // Add a permanently signed cookie to the jar c.permanent().signed() .add(Cookie::new("key".to_string(), "value".to_string()));
pub fn encrypted(&'b self) -> CookieJar<'b>
[src]
pub fn encrypted(&'b self) -> CookieJar<'b>
Creates a child encrypted cookie jar.
All cookies read from the child jar must be encrypted and signed by a valid key and all cookies written will be encrypted and signed automatically.
Example
let c = CookieJar::new(b"f8f9eaf1ecdedff5e5b749c58115441e"); // Add a signed and encrypted cookie to the jar c.encrypted().add(Cookie::new("key".to_string(), "value".to_string())); // Add a permanently signed and encrypted cookie to the jar c.permanent().encrypted() .add(Cookie::new("key".to_string(), "value".to_string()));
pub fn permanent(&'b self) -> CookieJar<'b>
[src]
pub fn permanent(&'b self) -> CookieJar<'b>
Creates a child jar for permanent cookie storage.
All cookies written to the child jar will have an expiration date 20 years into the future to ensure they stick around for a long time.
pub fn delta(&self) -> Vec<Cookie>
[src]
pub fn delta(&self) -> Vec<Cookie>
Calculates the changes that have occurred to this cookie jar over time,
returning a vector of Set-Cookie
headers.
pub fn iter(&self) -> Iter
[src]
pub fn iter(&self) -> Iter
Return an iterator over the cookies in this jar.
This iterator will only yield valid cookies for this jar. For example if this is an encrypted child jar then only valid encrypted cookies will be yielded. If the root cookie jar is iterated over then all cookies will be yielded.