THRIFT-6010: Add PSR-18 HTTP transport (TPsrHttpClient) for PHP#3492
Open
sveneld wants to merge 1 commit into
Open
THRIFT-6010: Add PSR-18 HTTP transport (TPsrHttpClient) for PHP#3492sveneld wants to merge 1 commit into
sveneld wants to merge 1 commit into
Conversation
Client: php TPsrHttpClient is a new HTTP transport backed by any PSR-18 ClientInterface, with PSR-7/PSR-17 factories auto-discovered via php-http/discovery when not explicitly injected. Concrete clients (Guzzle, Symfony HttpClient, php-http/ curl-client) are listed under composer "suggest". Existing TCurlClient and THttpClient transports are left untouched. Generated-by: Claude Opus 4.7 <noreply@anthropic.com>
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
Adds
Thrift\Transport\TPsrHttpClient— an HTTP transport for Thrift clients backed by any PSR-18Psr\Http\Client\ClientInterface. Concrete HTTP clients ship under Composersuggest; users pick Guzzle, Symfony HttpClient, orphp-http/curl-clientand discovery wires them up.Purely additive:
TCurlClientandTHttpClientare untouched.Design
(string $url, ?ClientInterface $client = null, ?RequestFactoryInterface $requestFactory = null, ?StreamFactoryInterface $streamFactory = null)— URL is a single string; PSR-7 / PSR-17 handle parsing.php-http/discoveryauto-discovers client + factories when not explicitly injected; failures surface asTTransportException::NOT_OPENwith an actionable message ("Install one of: guzzle, symfony, curl-client").NetworkExceptionInterface→NOT_OPEN. OtherClientExceptionInterfacesubtypes plus\InvalidArgumentException/\RuntimeExceptionfrom PSR-7 builders →NOT_OPEN/UNKNOWNas appropriate. Non-200 status →UNKNOWN.ClientInterface. The transport itself stores no static state.Composer
require:psr/http-client,psr/http-factory,psr/http-message,php-http/discovery(all MIT — ASF Category A).require-dev:nyholm/psr7for the unit-test suite.suggest:guzzlehttp/guzzle,symfony/http-client,php-http/curl-client.config.allow-plugins:php-http/discovery: true(required by Composer 2.2+).Tests
New
TPsrHttpClientTest— 15 cases using an injected fakeClientInterfaceand realnyholm/psr7factories. Nophpmock. Covers default + custom headers, URL pass-through (6 variants), empty body, response buffer, status-code rejection, network / client / invalid-URL exception mapping.CI green on PHP 8.1 – 8.5 plus the existing PHP cross-test job.
Test plan
composer phpstan(level 6) cleanvendor/bin/phpunit -c lib/php/phpunit.xml --testsuite Unitcleanmake stylecleancross-test (cpp, go, rs, cpp, py, php, nodejs, nodets)passTPsrHttpClientUsage
728249b23)composer.json[skip ci]— n/a (code change)Generated-by: Claude Opus 4.7 noreply@anthropic.com