fix(downloads): send browser-like headers and reuse one HTTP client - #1404
Merged
Merged
Conversation
Owner
|
@davidscottpope-gif Thanks for the contribution. It is merged and shipped in pake-cli 3.17.3, together with a few changes made before merging: the browser download fallback stays in place when native IPC is not allowed, the shared HTTP client reports an error instead of panicking, files are flushed before the success toast, and credentials are stripped from the Referer. Redirects now keep the window's session cookies on each hop. Run |
Carry the calling webview context through validated redirects without leaking cookies or restoring sensitive referrer details. Match literal-IP cookies on macOS and flush asynchronous writes before reporting success.
Retain notification permission coverage together with authenticated download header assertions when integrating the reviewed changes on main.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
download_filebuilt a freshreqwestHTTP client for every file and sent only a Cookie header. To a host or CDN that filters on User-Agent or Referer, the request does not look like it came from the page, so a download can be rejected (or answered with an error page saved as the file) even though the same URL opens fine in the webview. Writes also used blockingstd::fsinside the async command.Solution
Send the headers the webview itself would send:
navigator.userAgentandwindow.location.hrefwith everydownload_filecall (all three call sites: link guard, image download, context menu).strict-origin-when-cross-originpolicy: full page URL with the fragment stripped for same-origin downloads, origin only for cross-origin, and no Referer on an https -> http downgrade or from a non-http(s) page.tokio::fsso the async runtime is not blocked (adds the tokio "fs" feature).Tests
event-link-guardexpectations for the new params.