Repository navigation
Conversation
…d before it is refused The default agent followed up to 5 redirects itself, so the policy saw only the first address: under the default https_only, an https:// address answering 302 to http:// was downloaded over http. The fetcher now follows redirects itself (agent max_redirects(0)), one at a time, each Location resolved against the address that answered and checked by the policy; more than 5 is refused. with_agent's doc asks for max_redirects(0) for the same reason. A request under an id already under way that would be refused at once (no url, a refused address, a path out of cache/) answered with that id, and poll took the answer for the running download's: its entry dropped (cancel no longer reached it, one more slot started) and the game got two answers. The id check now comes first. Tests: redirect resolution (absolute, //, /, beside, query); a local server's redirects beside the path and from the root followed, one to a refused address and a loop refused with nothing written, a repeated id with a file:// url ignored. The new test fails with the per-hop check removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Two fixes to
renderer/src/assets.rs(#283).Redirects skipped the policy.
AssetFetcher::newbuilt its agent withmax_redirects(5), and ureq follows those itself. It checks the scheme on a hop only whenhttps_onlyis set, which it wasn't (ureq 3.5.2run.rs:155). So the policy only saw the first address. Under the defaulthttps_only(), anhttps://address that answers302 Location: http://…was downloaded over plain http. A customwith_policycheck was skipped on every hop after the first in the same way.The fetcher now follows redirects itself, one hop at a time. The agent is built with
max_redirects(0). EachLocationis resolved against the address that answered it (absolute,//host,/path, or a path relative to it) and checked by the policy. More than 5 redirects is refused. Thewith_agentdoc now asks formax_redirects(0)for the same reason. Redirects an app's own agent follows are still that agent's to check.A repeated id that gets refused broke the first request's tracking. Take an
assets.fetchwhoseidis already under way but which is refused at once (no url, an address the policy refuses, a path outsidecache/). It sent its refusal under that id, andpolltook it as the running download's answer. The running entry was dropped, so a laterassets.cancelno longer reached it and one more queued download started. The game also got two answers for the id. The duplicate-id check now runs before the refusals, so the second request is ignored, as a valid duplicate already was.Tests (
cargo test --lib assets: 5 pass):redirects_resolve_from_the_answering_address: how aLocationresolves.redirects_are_held_to_the_policy: runs against a local server. A redirect relative to the path and one from the root are followed. A redirect to an address the policy refuses and a redirect loop are both refused, with nothing written. A repeated id with afile://url is ignored, and the first request is answered once. With the per-hop check removed, this test fails.RUNTIME.md "Assets" is updated to match.
Not changed, but worth noting: two requests with different ids for the same
paththat run at once both write<path>.part. They share the temp file, so a body from one url can end up recorded under the other's sha256. Fixing that needs a per-path lock or a unique part name. I left it to you to decide whether that's worth doing.🤖 Generated with Claude Code