Repository navigation
Conversation
With follow_location enabled, which is the default, PHP's http wrapper lists the headers of every response in the redirect chain. The transport took the status code of the first response and turned each further status line into a header without a name, which Diactoros rejects, so every redirect ended in an InvalidArgumentException. Use only the headers of the last response and skip lines that are not headers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 12, 2026
Closed
Contributor
Author
|
Approved |
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.
Summary of Changes
The stream transport failed on every redirect. With
follow_locationenabled (the default), PHP's http wrapper puts the headers of every response in the chain intowrapper_data. The transport took the status code of the first response (e.g.302) and turned each further status line (HTTP/1.1 200 OK) into a header without a name, which Diactoros rejects:This change keeps only the header block of the last response, and
AbstractTransport::processHeaders()now skips lines that are notName: valueheaders instead of creating a header with an empty name.Testing Instructions
Tests/Transport/StreamRedirectTest.php(new) uses the newTests/stubs/redirect.php, which redirects a configurable number of times with a relativeLocationbefore reachingjhttp_stub.php:200ofjhttp_stub.phpwithout theLocationheader of the redirects (fails before the change with the exception above);follow_location => falsethe302and itsLocationare returned.Serve the stubs and run the suite:
php -S 127.0.0.1:8080 -t Tests/stubs, thenvendor/bin/phpunit(CI does the same).Documentation Changes Required
docs/classes/TransportInterface.md: the options table now lists the stream transport forfollow_locationand says that the response at the end of the chain is returned.Related to #81 (transport test setup); both PRs touch
Tests/, but not the same files.🤖 Generated with Claude Code