Repository navigation
feat(client): cap redirect hops and resend in-memory bodies on 307/308 - #13910
Merged
Merged
Conversation
withFollowRedirects() takes an optional maxHops (default Redirect::MAX_HOPS). The cURL adapter sends in-memory bodies up to php://temp's 2 MiB buffer as CURLOPT_POSTFIELDS, which cURL can replay after a 307/308; larger and file-backed bodies keep streaming. Needed so #13893 can keep fetch's 5-hop cap and body-preserving redirects.
Contributor
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
cURL adds Content-Type: application/x-www-form-urlencoded to string POSTFIELDS. When the request sets no Content-Type, the header is now suppressed, matching the streaming path.
TorstenDittmann
approved these changes
Sep 26, 2026
This was referenced Sep 26, 2026
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.
What does this PR do?
Two
packages/clientchanges that #13893 needs to keeputopia-php/fetch's redirect behaviour.1. Redirect hop cap
CURLOPT_MAXREDIRSfetch capped redirects at 5; client always allowed 50. Negative values throw
ValueError. CustomAdapterimplementations must add the parameter (CHANGELOG).2. Resend in-memory bodies on 307/308
CURLOPT_READFUNCTION; 307/308 fails withnecessary data rewind was not possibleCURLOPT_POSTFIELDS; cURL replays itTest Plan
bin/monorepo check clientbin/monorepo test clientNew tests: 5 hops allowed and a 6th rejected, zero and negative limits (both adapters); POST body across 307 and 308 (both adapters); an 8 MiB temporary body stays memory-bounded.
Related PRs and Issues
🤖 Generated with Claude Code