fix: keep server redirect queries separate from initial request parameters

AF
10h ago
+116-0

Summary

safe_get(..., params=...) forwards the original query parameters to every request in a redirect chain. A server redirect to /document?download=1 therefore receives an extra copy of the initial request's parameters, and a redirect intended to replace a parameter gets both values. This differs from Requests' redirect behavior and can fetch the wrong resource or fail a signed target URL.

Remove the initial params argument after resolving the first redirect against the prepared response URL. Each subsequent query comes from the resolved Location; parameters still reach the initial request normally. URL validation and cross-origin header handling continue to run for each hop.

Validation

  • The new cases produce 11 failures and 2 passing controls on the original source.
  • The new tests and complete existing safe-HTTP suite report 93 passed on Python 3.12.
  • Tests use a real local HTTP server and compare request paths with the installed Requests client across 301/302/303/307/308 responses, repeated initial parameters, existing URL queries, server replacement queries and multiple redirect hops. They also check requests without redirects and unchanged caller-owned parameter lists.
  • Repository-configured Ruff check, format check and source-integrity checks pass.
  • Validation run and JUnit artifacts.

Checklist

  • User-facing conventional-commit title.
  • Maintainer: please apply the bug category label.