[][src]Struct reqwest::header::Cookie

pub struct Cookie(_);

Cookie header, defined in RFC6265

If the user agent does attach a Cookie header field to an HTTP request, the user agent must send the cookie-string as the value of the header field.

When the user agent generates an HTTP request, the user agent MUST NOT attach more than one Cookie header field.

Example values

Example

use hyper::header::{Headers, Cookie};

let mut headers = Headers::new();
let mut cookie = Cookie::new();
cookie.append("foo", "bar");

assert_eq!(cookie.get("foo"), Some("bar"));

headers.set(cookie);

Methods

impl Cookie
[src]

Creates a new Cookie header.

Sets a name and value for the Cookie.

Note

This will remove all other instances with the same name, and insert the new value.

Append a name and value for the Cookie.

Note

Cookies are allowed to set a name with a a value multiple times. For example:

use hyper::header::Cookie;
let mut cookie = Cookie::new();
cookie.append("foo", "bar");
cookie.append("foo", "quux");
assert_eq!(cookie.to_string(), "foo=bar; foo=quux");

Get a value for the name, if it exists.

Note

Only returns the first instance found. To access any other values associated with the name, parse the str representation.

Important traits for CookieIter<'a>

Iterate cookies.

Iterate cookie (key, value) in insertion order.

use hyper::header::Cookie;
let mut cookie = Cookie::new();
cookie.append("foo", "bar");
cookie.append(String::from("dyn"), String::from("amic"));

let mut keys = Vec::new();
let mut values = Vec::new();
for (k, v) in cookie.iter() {
    keys.push(k);
    values.push(v);
}
assert_eq!(keys, vec!["foo", "dyn"]);
assert_eq!(values, vec!["bar", "amic"]);

Trait Implementations

impl Clone for Cookie
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Cookie
[src]

Formats the value using the given formatter. Read more

impl Display for Cookie
[src]

Formats the value using the given formatter. Read more

impl PartialEq<Cookie> for Cookie
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Header for Cookie
[src]

Returns the name of the header field this belongs to. Read more

Parse a header from a raw stream of bytes. Read more

Format a header to outgoing stream. Read more

Auto Trait Implementations

impl Send for Cookie

impl Sync for Cookie

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> From for T
[src]

Performs the conversion.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

Converts the given value to a String. Read more

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Important traits for &'a mut W

Immutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Important traits for &'a mut W

Mutably borrows from an owned value. Read more

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more