-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat: add tauri::Webview::cookies_by_url()
and tauri::Cookie
#12665
base: dev
Are you sure you want to change the base?
Conversation
e2ca406
to
bccd107
Compare
Package Changes Through fdbefddThere are 8 changes which include tauri with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-cli with minor, tauri-utils with minor, @tauri-apps/api with minor, @tauri-apps/cli with minor, tauri-bundler with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
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.
thank you!!
I chose not to expose wry::webview::cookies() as it seemed to have an implementation note that it didn't work on Android at the moment.
It would be fine to do the same in tauri as well (having this function return an empty vec with a platform-specific note)
crates/tauri/src/webview/mod.rs
Outdated
@@ -1157,6 +1158,11 @@ impl<R: Runtime> Webview<R> { | |||
Ok(()) | |||
} | |||
|
|||
/// Returns all cookies for a specified URL including HTTP-only and secure cookies. |
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.
Can you add a note about the scheme requirements here? imo quite important
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.
I've added a note. This actually seems more of a bug/runtime limitation than anything. I would imagine this is because the tauri://
protocol behaves like the the file://
protocol in browsers and doesn't actually expose a functional cookie store.
I've added the relevant note and the I've also gone in and fixed up my fustfmt and clippy issues. |
As I'm testing this more deeply, I'm finding some concerning going. Fetching cookies is occasionally hanging the entire process. I will try to dig in some more. |
So after testing a bit more I've narrowed down the source of the hangs. It seems to happen in the MacOS implemenation specifically getting caught up in wry's I've gone and made a PR over on wry to resolve it tauri-apps/wry#1486 |
Closes
Related
WebView::cookies
andWebView::cookies_for_url
wry#1394Related issues not fully handled by this PR:
Changes
Webview::cookies_for_url()
andtauri::Cookie
Implementation notes
I'm open to any requested changes here, but here's how I've gone about this:
cookie::Cookie
as a re-export fromtauri_runtime::Cookie
andtauri::Cookie
. Notably I did not re-export thewry::Cookie
which is a re-export ofcookie::Cookie
sincetauri_runtime
does not have a dependency onwry
.cookies_for_url()
on the webview dispatcher and add an implementation for wry. I usedWebviewDispatcher::reparent
as my template for a dispatch the takes a parameter and returns a result.wry::webview::cookies()
as it seemed to have an implementation note that it didn't work on Android at the moment.Notes from my testing
Notably the wry support seems to only work when a site served over http (which is what I need it for). In my manual testing there doesn't seem to be a clear story for cookies on the
tauri://
protocol (and there probably shouldn't be?). In any case by linking this PR into my own project I am able to extract the cookies from content served over http/https.