Make cookies an optional feature (default off)

This commit is contained in:
Sean McArthur
2019-09-17 14:53:56 -07:00
parent 53495e1526
commit 0a87d3d7da
9 changed files with 85 additions and 28 deletions

View File

@@ -392,6 +392,11 @@ impl ClientBuilder {
/// .build()
/// .unwrap();
/// ```
///
/// # Optional
///
/// This requires the optional `cookies` feature to be enabled.
#[cfg(feature = "cookies")]
pub fn cookie_store(self, enable: bool) -> ClientBuilder {
self.with_inner(|inner| inner.cookie_store(enable))
}

View File

@@ -11,6 +11,7 @@ use serde::de::DeserializeOwned;
use super::client::KeepCoreThreadAlive;
use super::wait;
#[cfg(feature = "cookies")]
use crate::cookie;
use crate::{async_impl, StatusCode, Url, Version};
@@ -121,6 +122,11 @@ impl Response {
/// Retrieve the cookies contained in the response.
///
/// Note that invalid 'Set-Cookie' headers will be ignored.
///
/// # Optional
///
/// This requires the optional `cookies` feature to be enabled.
#[cfg(feature = "cookies")]
pub fn cookies<'a>(&'a self) -> impl Iterator<Item = cookie::Cookie<'a>> + 'a {
cookie::extract_response_cookies(self.headers()).filter_map(Result::ok)
}