-
Notifications
You must be signed in to change notification settings - Fork 30
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
Documentation for HTTPS Request with cookie? #18
Comments
I think adding docs for that would be great. Would you like to help out?
|
Would it be possible to have cookies as a first-class feature in ehttp? |
For reference: cookies can be accessed within response.headers. I'm not sure what you mean by "first class" ? I'm guessing either:
|
I see set-cookie in the response headers when visiting common websites. Yes I am asking about proper overall handling of the cookie including storage for both native and wasm egui applications, including storage. If I would need to make my own decisions about cookie storage, some guidance would be useful... |
I am currently building an app that needs to talk to a bunch of different REST APIs at different domains. A WASM app using ehttp is using (the same as all rust http libraries that compile to WASM i know of:) web-sys underneath, which provides binding to the browsers API. The browsers API, in contrast to native capabilities, enforces a lot of things that seem strange at first, but make sense if you think about security in the browser context. CORS and credential (e.g. cookie) handling will cause headaches if you are trying to cross-compile an app native/WASM that needs credentialed http requests to other web servers or REST APIs. Forget about CORS for a moment, as this assumes a lot of control and setup of the serving APIs. Most importantly, you can't read and send the cookie (or any credential afaik) like you would in a native app. There is not library you can wrap cookie handling in. The browser API forbids any code (including WASM) from sending a Cookie directly. You need to have the server send a Set-Cookie header, which will store it in the browser, and then tell web-sys (ultimately Fetch) to use that cookie in other requests. see: https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials I've made a PR to add the credential property to ehttp requests and tested it to work! |
Would it be possible to get some documentation on how to connect ehttp to perform https requests submitted with cookies, and how those cookies can be set via the response? Thanks!
The text was updated successfully, but these errors were encountered: