-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WASM cookies #2360
WASM cookies #2360
Conversation
I rebased the PR and made a few lint related commits. I reviewed the code again in light of #1449 and they are very similar. I put a lot more of the code in
|
PS. Maybe somewhere we should add a warning that WASM cookies won't work for WebSockets because according to https://devcenter.heroku.com/articles/websocket-security#authentication-authorization
The emphasis above is mine. The way cookies are implemented right now for WASM is very similar to how it is done for native which means in the browser it has to use JavaScript to set the cookies in the header which is not allowed for WebSocket requests. |
Namely - impl fmt::Debug for ClientBuilder - impl fmt::Debug for Client
Didn't fit well with merging of headers as the headers needed to be re-borrowed anyway to get url
Resolved dead_code warning and was useful even if not to me
clippy::redundant_pattern_matching
I think the current version PR as is still be helpful for more than just me.and the Websocket issue is kinda out of reach without trying to use the browsers cookie store. If we could merge this I'd appreciate it as I need it and don't really want to have to keep maintaining a fork. |
@c-git i'd recommend reaching out to sean on the #reqwest channel in the tokio discord to discuss a review directly - https://discord.gg/PWCbbMcy cc @seanmonstar as well |
Thank you I will do that. |
Thanks for working on this! I've wondered a bit, since reqwest on wasm is backed by |
I don't think we have a choice. The browser does not do it automatically. I'm not sure if there is a way to get it to do it for
It doesn't do it automatically (as I said not sure if there is a way to get it to).
I see what you mean and we cannot for WebSocket requests but for POST and GET which I tested we can. If it would help I can setup a test backend and client so we can see what happens. |
That's surprising. When I go to httpbin.org, open the browser console, and try out |
Thank you, for that information. I'll try to replicate what you did and then try my code again without cookie support in WASM and see what happens with the cookies more than just, tried and it doesn't work. That would actually be great. Feature flags in my code would be much easier to maintain than the fork I'm keeping going right now. |
Got tied up with other tasks and haven't been able to finish more detailed testing yet but it does seem that the browser does automatically manage the cookies (Sorry I'd gotten that wrong). Thus, personally I suspect that I no longer need this PR and didn't realize because it was working as expected just not why I expected. I'll still try to finish the testing as soon as I can and report back to see if this PR actually does anything at all because, based on the docs you referenced, setting cookie headers isn't allowed so maybe it doesn't do anything at all. I don't know if So far I tested disabling cookies and just running my app and it still works and the cookies show up in the browser dev tools. I want to test:
|
I setup a small test server and cookies are set, unset and sent but they are done by the browser. There is no cookie information in the incoming requests that reaches my code. If I set cookies manually in code they also do not reach the server. I'm sorry to have wasted your time with this. Have a good year. |
I got cookies working for WASM to the best of my knowledge. I tested it in my use case and it works. I'm not sure how to add tests for the cookie functionality I added for WASM.
I also have one part of the code that I'm unsure of because I didn't see a clear translation between the native version and the WASM version.
Please let me know what you need me to do or change anything (including if the code I mentioned that I was unsure of is ok).
Edit:
If you need this functionality before the PR lands you can add the following to the bottom of your
Cargo.toml
. If you need me to rebase to keep up with changes toreqwest
let me know (replying here would work as well) as I may not update unless a reason comes up such as I'm doing an updates on my dependencies or a security fixed comes out.