#reqwest see cookies stored in jar
34 messages · Page 1 of 1 (latest)
Actions for a persistent cookie store providing session support.
@meager dust ty so much
how do i access the Jar with this?
i cant create an instance or pass it the jar
Jar implements it so its just a method on Jar
thats the thing
i dont have it
reqwest = { version = "0.11.22", default-features = false, features = ["rustls-tls", "json", "multipart", "cookies"] }
im v confused
I assume rust analyzer saw it?
Sometimes rust analyzer gets a little confused and doesn't believe a trait is applicable for auto complete
il keep that in mind ty
i have been adding my cookies like:
self.steam_client.cookies.add_cookie_str(
cookie.value(),
&"https://buff.163.com"
.to_owned()
.parse::<reqwest::Url>()
.unwrap()
);
and i think they are not correct
as they have no name :D
now i can just add the headers cookies for each request!
wait can i not just pass the headers in and the set_cookies finds the cookies for me? :D
by this i mean i cant just pass:
let headers = response.headers();
like this:
self.cookies.set_cookies(headers, &url.to_owned().parse::<reqwest::Url>().unwrap());
wait why aren't you just using https://docs.rs/reqwest/latest/reqwest/struct.ClientBuilder.html#method.cookie_provider ?
A ClientBuilder can be used to create a Client with custom configuration.
i am:
pub async fn new(username: String, password: String) -> Self {
Self {
username,
password,
client: reqwest::ClientBuilder::new()
.cookie_store(true)
.build()
.unwrap(),
session_id: Self::_activate_session_id().await,
cookies: Jar::default(),
}
}
when i check if i have any cookies using .cookies it says None?
its because i need to move the cookies from reallycoolsite.com/path/newpath -> reallycoolsite.com
do cookies still get set if you do a post request
you never set the Jar as the cookie provider for the client builder
