-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a new trait, `CookieStore`, which allows for custom implementations of storage for a client's cookies. After implementing, you can call `ClientBuilder::cookie_provider` to use it over the default storage. The default store is exposed as `Jar`, to ease the most common use case which is to add a few cookies to the store when creating a client. Co-authored-by: Patrick Fernie <patrick.fernie@gmail.com>
- Loading branch information
1 parent
2414042
commit 12d7905
Showing
3 changed files
with
140 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12d7905
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default
Jar
implementation in this changeset is for simple case usage; namely loading some cookie values prior to starting a session.The API has also been expanded to include cookie_provider, which allows for other usage such as serializing/deserializing the store, as well as inspecting/modifying the store between requests. A sample such interaction was outlined in a prior PR, although the exact code example there is not updated to the API provided in this commit.
Note that this example is using the particular implementation of cookie storage provided by the cookie_store crate; with the introduction of the trait
reqwest::CookieStore
here, alternate implementations could be used instead, if there were some other particular API that made more sense in a different use case.