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
When building a Client that is supposed to interact with a server that makes use of cookies you have to enable the cookie feature and either:
call cookie_store(true) on the client builder -> this will internally create a new cookie store regardless if a store is already present. see the code here.
call cookie_provider(...) on the client builder with an Arc<dyn CookieStore> usually a cookie jar from the cookie_store crate. -> this will set the internal cookie store to the one given as an arguement. see the code here.
The issue now arises from the possible ordering of operations on the builder. You can accedentailly overwrite your own set cookie store by activating a cookie store. This behavior is not documented and was at least to me very confusing.
Possible Solutions
Add documentation to the cookie_store() method to make clear that this will create a new cookie store and overwrite any existing one.
Adapt the cookie_store() method to respect any existing cookie stores, not overwriting them. Though this would be an API change, no idea how many ppl are relying on this behavior.
I agree the documentation/API here is not very clear. Ideally, I think we would have one method taking some enum for disabling/enabling/or setting the store, but that would be an API change. Making the methods fallible (Err if the store isset multiple times) would also be an API change. #2111 attempts to clarify the documentation, instead.
Description
When building a Client that is supposed to interact with a server that makes use of cookies you have to enable the
cookie
feature and either:cookie_store(true)
on the client builder -> this will internally create a new cookie store regardless if a store is already present. see the code here.cookie_provider(...)
on the client builder with anArc<dyn CookieStore>
usually a cookie jar from thecookie_store
crate. -> this will set the internal cookie store to the one given as an arguement. see the code here.The issue now arises from the possible ordering of operations on the builder. You can accedentailly overwrite your own set cookie store by activating a cookie store. This behavior is not documented and was at least to me very confusing.
Possible Solutions
cookie_store()
method to make clear that this will create a new cookie store and overwrite any existing one.cookie_store()
method to respect any existing cookie stores, not overwriting them. Though this would be an API change, no idea how many ppl are relying on this behavior.Previous Work
#1104
The text was updated successfully, but these errors were encountered: