pub struct Cookie { /* private fields */ }Expand description
Represents a cookie created from Set-Cookie response header.
A Cookie can be parsed from the Set-Cookie value from an HTTP Response using the trait FromStr:
let cookie = Cookie::from_str("id=a3fWa; Expires=Wed, 21 Oct 2022 07:28:00 GMT");
See RFC6265 Set-Cookie for more information.
Implementations§
Source§impl Cookie
impl Cookie
Sourcepub fn new(name: String, value: String, domain: String, path: String) -> Cookie
pub fn new(name: String, value: String, domain: String, path: String) -> Cookie
Constructor. It takes ownership params:
name: Cookie namevalue: Cookie value, for binary data it is recommended Base64 encoding.domain: Cookie domain, sets hosts (domain and subdomains) to which the cookie will be sent, in includes subdomains. If not present inSet-Cookieheader, it is taken from the HTTP requestHostheaderpath: Cookie path, paths (same path or children) to which the cookie will be sent If not present inSet-Cookieheader, it is taken from the HTTP request path
Sourcepub fn expires(&self) -> Option<SystemTime>
pub fn expires(&self) -> Option<SystemTime>
When the Cookie expires, if None, it does not expire.
This value is obtained from Max-Age and Expires attributes (Max-Age has precedence)
Sourcepub fn same_site(&self) -> SameSiteValue
pub fn same_site(&self) -> SameSiteValue
Cookie Same-Site value (optional)
Sourcepub fn extensions(&self) -> &HashMap<String, String>
pub fn extensions(&self) -> &HashMap<String, String>
Cookie extendions
Sourcepub fn path_match(&self, request_path: &str) -> bool
pub fn path_match(&self, request_path: &str) -> bool
Checks if the request path match the cookie path.
Using RFC6265 Section 5.1.4 Algorithm.
Sourcepub fn domain_match(&self, request_domain: &str) -> bool
pub fn domain_match(&self, request_domain: &str) -> bool
Checks if the request domain match the cookie domain.
Using RFC6265 Section 4.1.1.3.
Trait Implementations§
impl Eq for Cookie
Auto Trait Implementations§
impl Freeze for Cookie
impl RefUnwindSafe for Cookie
impl Send for Cookie
impl Sync for Cookie
impl Unpin for Cookie
impl UnwindSafe for Cookie
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more