fix: preserve mirror URL path when rewriting requests#2183
fix: preserve mirror URL path when rewriting requests#2183mohitdebian wants to merge 7 commits intoconda:mainfrom
Conversation
|
This PR should address the mirror path rewriting issue described in #1283. The change replaces
Please let me know if any adjustments are needed |
|
Please fill in the pr template |
|
I've updated the pr description to follow the template. Let me know if anything else needs adjustment |
|
rattler/.github/pull_request_template.md Lines 14 to 20 in 983647b |
|
sorry for being unclear earlier, i updated our pr template to reflect this better: #2204 |
Replace Url::join() with manual path concatenation in the mirror middleware. Url::join() follows RFC 3986 and replaces the last path segment of the base URL instead of appending when no trailing slash is present. This caused mirror URLs with path components (e.g. https://my-custom-url/channel) to lose their path during rewriting. Fixes conda#1283
Replace `Url::join()` with explicit path concatenation in the mirror middleware. `Url::join()` follows RFC3986 relative resolution which replaces the last path segment when the base URL has no trailing slash. This caused mirror URLs with path components (e.g. https://my-custom-url/channel) to lose their path during rewriting. The new implementation preserves the mirror base path and safely appends the remaining request path. Adds a regression test verifying correct path rewriting.
6d3b35b to
be4e008
Compare
| features = ["gcs", "s3"] | ||
|
|
||
| [dependencies] | ||
| rattler_conda_types = { workspace = true } |
There was a problem hiding this comment.
Mm sucks a little bit that we have to add this dependency just to get to that type. Maybe we should not do it and use your previous fix instead. Sorry for the noise.
There was a problem hiding this comment.
Mm sucks a little bit that we have to add this dependency just to get to that type. Maybe we should not do it and use your previous fix instead. Sorry for the noise.
no worries about the noise i agree that adding a dependency just for that type might not be ideal if you'd prefer the previous implementation i can revert the change and update the pr
Description
Fix mirror URL rewriting when the mirror URL contains a path component.
Previously the mirror middleware used
Url::join()when constructing mirrored request URLs.Because
Url::join()follows RFC3986 semantics, the last path segment of the base URL can betreated as a file when the base URL does not end with a trailing slash.
This caused mirror URLs such as
https://my-custom-url/channelto lose their path during rewriting.Example
Upstream request
Mirror configuration
Incorrect result
Expected result
Fixes #1283
How Has This Been Tested?
cargo test -p rattler_networkingAI Disclosure
Tools: N/A
Checklist