Trait fav_core::config::HttpConfig
source · pub trait HttpConfig {
// Required methods
fn headers(&self) -> HeaderMap;
fn cookies(&self) -> &HashMap<String, String>;
fn cookies_mut(&mut self) -> &mut HashMap<String, String>;
// Provided methods
fn extend_cookies(&mut self, cookies: HashMap<String, String>) { ... }
fn cookie_value(
&self,
keys: impl IntoIterator<Item = impl AsRef<str>>
) -> HeaderValue { ... }
}Expand description
A HttpConfig, including headers and cookies.
§Example
impl HttpConfig for Conf {
fn headers(&self) -> HeaderMap {
let mut hp = HeaderMap::new();
hp.insert(header::USER_AGENT, "Mozilla/5.0".parse().unwrap());
hp
}
fn cookies(&self) -> &HashMap<String, String> {
&self.cookies
}
fn cookies_mut(&mut self) -> &mut HashMap<String, String> {
&mut self.cookies
}
}Required Methods§
The cookies. HttpConfig::cookie_value uses this to generate the Cookie header.
§Caution
HttpConfig::cookie_value will omit the keys that are not in the cookies
without any warning.
The mutable reference to the cookies
Provided Methods§
Set the cookies
Acquire the cookie value by keys
Object Safety§
This trait is not object safe.