Support saving/loading the cooke store as JSON #1048
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is inspired by some of the code & discussion from #1009
I'm looking for feedback, I don't think this is ready as-is.
API Changes
save_cookies_json
to theClient
load_cookies_json
to theClientBuilder
This sort-of exposes the json format as part of the API. Changes to
cookie_store
could result in old JSON files being unreadable. Given that this would just be an error, and not an API breakage, I'm not sure if that's a concern.Questions
1) Do we make
reqwest::cookie::CookieStore
pub?cookie_store::CookieStore
does not support.clone()
. Do we care thatload_cookies_json
would be done on aCookieStore
, butsave_cookies_json
would be done directly on aClient
?2) Error handling?
cookie_store
crate raises eitherBox<dyn Error>
or its ownCookieError
enum. This PR managed to dodge the issue by havingsave_cookies_json
create anio::Error
, andload_cookies_json
used theKind::Builder
enum.Kind::Cookie
? Other ideas?3) Arguments for
save_cookies_json
persistent
andexpired
. I think the "right" thing is to only save persistent non-expired cookies, but there are reasons to want more options: