Skip to content

How to clear cookies in reqwest client? #2285

Closed Answered by pfernie
20-buck-spin asked this question in Q&A
Discussion options

You must be logged in to vote

reqwest_cookie_store is a simple crate; if you want to avoid an extra dependency you can implement its functionality directly in your code, and use cookie_provider(cookie_store) instead of cookie_store(true). Note that reqwest::cookies::Jar uses cookie_store::CookieStore internally, so you already have a (transitive) dependency on the cookie_store crate when you enable feature cookies in reqwest. See #1437 in regards to supporting this directly via reqwest::cookies::Jar.

use std::sync::{Arc, RwLock};

use cookie_store::{RawCookie, RawCookieParseError};
use reqwest::{blocking::ClientBuilder, header::HeaderValue};

struct CookieStoreWrapper(RwLock<cookie_store::CookieStore>);

impl CookieSt…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@20-buck-spin
Comment options

Answer selected by 20-buck-spin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants