[13.x] Normalize HTTP client header values#60292
Merged
Merged
Conversation
ceb4f35 to
b4a1092
Compare
b4a1092 to
a87be12
Compare
Member
|
Thanks! |
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.
This is needed because Laravel's HTTP client can receive numeric, boolean, existing
Illuminate\Support\Stringable, and empty-array header values from its own fluent API before those values reach Guzzle's PSR-7 implementation. Beforeguzzlehttp/psr72.11, scalar and null header values were accepted and cast to strings, and empty arrays were accepted without an immediate failure. Inguzzlehttp/psr72.11, those compatibility cases started emitting deprecations becauseguzzlehttp/psr73.0 requires header values to already be strings or arrays of strings and rejects empty header arrays.This change keeps that transition explicit at Laravel's boundary by serializing supported scalar request header values and preserving Laravel's existing
Illuminate\Support\Stringablenormalization before values are passed to Guzzle, serializing empty header arrays to an empty string for compatibility, and rejecting unsupported header values before lower-level PSR-7 validation sees them. It also applies the same supported header-value normalization to fake response headers before constructingGuzzleHttp\Psr7\Responseinstances. It does not add native PHPStringableheader support becauseguzzlehttp/psr7did not previously accept those objects as header values, and it opens up the ability for a future PR to more easily co-support Guzzle 7, which usesguzzlehttp/psr72.x, and Guzzle 8, which usesguzzlehttp/psr73.x.There is a similar PR recently merged into the AWS PHP SDK: aws/aws-sdk-php#3289.