Repository navigation
fix(http): name a redirected download after the URL that answered - #620
Conversation
A link that redirects to the file, such as Mozilla's https://download.mozilla.org/?product=firefox-latest-ssl&os=osx, was saved as "download", without an extension, as Ketch named files after the URL it was given. Browsers name them after the URL that answered, here "Firefox 158.0.1.dmg". ServerInfo now carries that URL, and without a Content-Disposition the download is named after it when its name has an extension, else after the requested URL when that one has one, so a link like asset.zip served from an opaque storage key keeps its name.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9dd31ece81
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…irect .mobileconfig and .safetensors are extensions too: drop the ten-character limit, keeping extensions of letters and digits.
Found while downloading real links with the CLI. Mozilla's official Firefox link
was saved as
download, with no extension, because Ketch named files after the URL it was given. Mozilla sends noContent-Disposition. Browsers name such files after the URL that answered:Firefox 158.0.1.dmg. Links that redirect to the real file are everywhere (…/download?id=5,file.php?id=3, "latest" links).What changes
ServerInfo.url: the URL that answered, after the redirects the engine followed.KtorHttpEnginesets it forHEADand theGETprobe; engines that don't say leave itnull.Content-Disposition, which still wins,HttpDownloadSource.resolvenames the file withDefaultFileNameResolver.fromUrls(requested, answered):download→Firefox 158.0.1.dmg,file.php→report.pdf);asset.zipserved from an opaque storage key such asobjects/4f1d…?X-Amz-…keeps its name);Verification
ketchfrom this branch: the Firefox link is saved asFirefox 158.0.1.dmg(before:download). GitHub release assets (named byContent-Disposition), plain URLs and redirects that keep their name are unchanged.DefaultFileNameResolverTest.fromUrls_*(redirect targets with and without extensions, script links, no answered URL),HttpDownloadSourceTest.resolve_redirectedLink_isNamedAfterTheAnsweringUrl, andKtorHttpEngineRedirectTestnow checksServerInfo.urlafter a redirect to another port../gradlew :library:core:jvmTest --tests '*DefaultFileNameResolverTest*' --tests '*HttpDownloadSourceTest*' --tests '*ResolveUrlTest*' --tests '*ServerInfoTest*' :library:ktor:jvmTestpasses.