Remove Agent::set_cookie
Preloading an agent with cookies can be done by providing a prepared cookie store using `AgentBuilder`. At this point, we don't want direct state mutation on the `Agent`, so this fn goes away. Context: https://github.com/algesten/ureq/issues/203#issuecomment-716385310
This commit is contained in:
19
src/agent.rs
19
src/agent.rs
@@ -7,7 +7,7 @@ use crate::resolve::{ArcResolver, StdResolver};
|
||||
use std::time::Duration;
|
||||
|
||||
#[cfg(feature = "cookies")]
|
||||
use {crate::cookies::CookieTin, cookie::Cookie, cookie_store::CookieStore, url::Url};
|
||||
use {crate::cookies::CookieTin, cookie_store::CookieStore};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AgentBuilder {
|
||||
@@ -107,23 +107,6 @@ impl Agent {
|
||||
Request::new(self.clone(), method.into(), path.into())
|
||||
}
|
||||
|
||||
/// Store a cookie in this agent.
|
||||
///
|
||||
/// ```
|
||||
/// let agent = ureq::agent();
|
||||
///
|
||||
/// let cookie = ureq::Cookie::build("name", "value")
|
||||
/// .secure(true)
|
||||
/// .finish();
|
||||
/// agent.set_cookie(cookie, &"https://example.com/".parse().unwrap());
|
||||
/// ```
|
||||
#[cfg(feature = "cookies")]
|
||||
pub fn set_cookie(&self, cookie: Cookie<'static>, url: &Url) {
|
||||
self.state
|
||||
.cookie_tin
|
||||
.store_response_cookies(Some(cookie).into_iter(), url);
|
||||
}
|
||||
|
||||
/// Make a GET request from this agent.
|
||||
pub fn get(&self, path: &str) -> Request {
|
||||
self.request("GET", path)
|
||||
|
||||
Reference in New Issue
Block a user