Repository navigation
Conversation
The transports checked for Content-Type, Content-Length, Connection and
Host with isset() on the exact spelling, so a "content-type" passed by the
caller got a second, form-encoded Content-Type added, and a lower-case
"host" produced two Host headers in the socket transport. The headers
option of Http was merged the same way.
Header values from sendRequest() are lists. The cURL transport used the raw
value for CURLOPT_ENCODING ("Array to string conversion", encoding "Array")
and passed it to strpos() for the multipart check (TypeError).
Look up headers case-insensitively, replace Content-Length in any case, and
join list values before using them for cURL options.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 12, 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.
Summary of Changes
Two problems with request headers. They are in one PR because both change the same lines of the cURL transport.
Case-sensitive header lookups. HTTP header names are case-insensitive, but the transports checked
isset($headers['Content-Type']),isset($headers['Connection'])andisset($headers['Host'])on the exact spelling, andHttpmerged itsheadersoption the same way. Passingcontent-type: application/jsonwith a body added a secondContent-Type: application/x-www-form-urlencoded; a lower-casehostgave twoHostheaders in the socket transport;acceptin a request did not overrideAcceptfrom the options. (PHP 8.3's built-in web server even crashed withzend_mm_heap corruptedon the duplicateContent-Typewhile reproducing this.)List values from
sendRequest(). PSR-7getHeaders()returns a list per header. The cURL transport put the raw value intoCURLOPT_ENCODING("Array to string conversion", encodingArray, so cURL no longer decompressed responses) and passed it tostrpos()for the multipart check, aTypeErrorwhen the data is an array.AbstractTransportgets two helpers,getHeaderValue()(case-insensitive lookup, list values joined with,) andsetHeader()(replaces a header in any case). The transports use them forContent-Type,Content-Length,Connection,HostandAccept-Encoding;Http::makeTransportRequest()compares the option header names case-insensitively.Testing Instructions
Tests/Transport/HeaderNormalisationTest.php(new):content-type: application/jsonreaches the stub with that content type (before: overridden by the form-encoded one);Accept-Encodingas a list is sent without PHP warnings (before: "Array to string conversion" with cURL);multipart/form-datacontent type and array data (before:TypeError).Tests/HttpOptionHeadersTest.php(new):acceptin a request overridesAcceptfrom theheadersoption.jhttp_stub.phpnow also echoes the request headers (getallheaders()).Documentation Changes Required
docs/overview.md, "Working with options": header names are compared case-insensitively and values may be lists.🤖 Generated with Claude Code