You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can someone add an example file for how to access and set cookies on the Client via CookieStore/cookie_provider rather than from a Request and Response?
I tried creating an Arc<Jar> and passing it to .cookie_provider() but it doesn't get mutated, it stays empty despite the Response containing the returned set cookies and future Requests containing the cookies.
let cookies = Arc::new(Jar::default());// Load cookies from the last session
config
.cookies.iter().for_each(|cookie| cookies.add_cookie_str(cookie,&BASE_URL));let client = Client::builder().cookie_provider(cookies.clone()).cookie_store(true).build()?;// ... requests ...println!("Cookies: {cookies:#?}");// Save cookies for the next session
config.cookies = cookies
.cookies(&BASE_URL).iter().map(HeaderValue::to_str).filter_map(Result::ok).map(String::from).collect::<Vec<_>>();
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Can someone add an example file for how to access and set cookies on the Client via CookieStore/cookie_provider rather than from a Request and Response?
I tried creating an
Arc<Jar>
and passing it to.cookie_provider()
but it doesn't get mutated, it stays empty despite the Response containing the returned set cookies and future Requests containing the cookies.Beta Was this translation helpful? Give feedback.
All reactions