[ 
https://issues.apache.org/jira/browse/THRIFT-6010?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Volodymyr Panivko updated THRIFT-6010:
--------------------------------------
    Description: 
Add a new HTTP client transport for the PHP library: 
{{Thrift\Transport\TPsrHttpClient}}. Purely additive — existing {{TCurlClient}} 
and {{THttpClient}} are untouched.

*Design*
* Constructor: {{(string $url, ?ClientInterface $client = null, 
?RequestFactoryInterface $requestFactory = null, ?StreamFactoryInterface 
$streamFactory = null)}}.
* Delegates all network I/O to a PSR-18 {{ClientInterface}}; PSR-7 messages and 
PSR-17 factories handle request/URL construction. URL parsing, port-suppression 
and percent-encoding are no longer hand-rolled.
* When client / factories are omitted, {{php-http/discovery}} resolves them. 
Discovery failures are wrapped as {{TTransportException::NOT_OPEN}} with an 
actionable "Install one of: guzzlehttp/guzzle, symfony/http-client, 
php-http/curl-client" message instead of an autoloader-level fatal.
* PSR-7 {{\InvalidArgumentException}} and {{\RuntimeException}} from 
{{createStream}}/{{createRequest}}/{{withHeader}} are wrapped as 
{{TTransportException::NOT_OPEN}}. PSR-18 {{NetworkExceptionInterface}} maps to 
{{NOT_OPEN}}, other {{ClientExceptionInterface}} subtypes and non-200 responses 
map to {{UNKNOWN}}.

*Composer*
* {{require}}: {{psr/http-client}}, {{psr/http-factory}}, {{psr/http-message}}, 
{{php-http/discovery}}.
* {{suggest}}: {{guzzlehttp/guzzle}}, {{symfony/http-client}}, 
{{php-http/curl-client}}.
* {{require-dev}}: {{nyholm/psr7}} for the unit-test suite.
* {{config.allow-plugins}}: {{php-http/discovery}} explicitly allow-listed 
(Composer 2.2+ requirement).

*Tests*
New {{TPsrHttpClientTest}} (15 cases) uses an injected fake {{ClientInterface}} 
and real {{nyholm/psr7}} factories — no {{phpmock}} required. Covers headers, 
URL pass-through, exception mapping (network, client, invalid URL), empty body, 
buffer lifecycle, status codes.

  was:
Add a new HTTP client transport for the PHP library: 
{{Thrift\Transport\TPsrHttpClient}}.

*Design*
* Constructor: {{(string $url, ?ClientInterface $client = null, 
?RequestFactoryInterface $requestFactory = null, ?StreamFactoryInterface 
$streamFactory = null)}}.
* The transport delegates all network I/O to a PSR-18 {{ClientInterface}}; 
PSR-7 messages and PSR-17 factories handle request/URL construction. URL 
parsing, port-suppression and percent-encoding are no longer hand-rolled.
* When client / factories are omitted, {{php-http/discovery}} resolves them. 
Discovery failures are wrapped as {{TTransportException::NOT_OPEN}} with an 
actionable "Install one of: guzzlehttp/guzzle, symfony/http-client, 
php-http/curl-client" message instead of an autoloader-level fatal.
* PSR-7 {{\InvalidArgumentException}} and {{\RuntimeException}} from 
{{createStream}}/{{createRequest}}/{{withHeader}} are wrapped as 
{{TTransportException::NOT_OPEN}}. PSR-18 {{NetworkExceptionInterface}} maps to 
{{NOT_OPEN}}, other {{ClientExceptionInterface}} subtypes and non-200 responses 
map to {{UNKNOWN}}.

*Composer*
* {{require}}: {{psr/http-client}}, {{psr/http-factory}}, {{psr/http-message}}, 
{{php-http/discovery}}.
* {{suggest}}: {{guzzlehttp/guzzle}}, {{symfony/http-client}}, 
{{php-http/curl-client}}.
* {{require-dev}}: {{nyholm/psr7}} for the unit-test suite.
* {{config.allow-plugins}}: {{php-http/discovery}} explicitly allow-listed 
(Composer 2.2+ requirement).

*Deprecations*
* {{TCurlClient}} marked {{@deprecated}}; will be removed in the next version. 
Behaviour unchanged.
* {{THttpClient}} (stream wrapper via {{fopen}}) is left as a dependency-free 
alternative — not deprecated.

*Tests*
New {{TPsrHttpClientTest}} (15 cases) uses an injected fake {{ClientInterface}} 
and real {{nyholm/psr7}} factories — no {{phpmock}} required. Covers headers, 
URL pass-through, exception mapping (network, client, invalid URL), empty body, 
buffer lifecycle, status codes.

*Migration*
See {{lib/php/UPGRADING.md}} for Guzzle/Symfony/curl-client install examples 
and the new constructor signature.

        Summary: Add PSR-18 HTTP transport (TPsrHttpClient) for PHP library  
(was: Add PSR-18 HTTP transport (TPsrHttpClient) and deprecate TCurlClient in 
PHP library)

> Add PSR-18 HTTP transport (TPsrHttpClient) for PHP library
> ----------------------------------------------------------
>
>                 Key: THRIFT-6010
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6010
>             Project: Thrift
>          Issue Type: Improvement
>          Components: PHP - Library
>    Affects Versions: 0.24.0
>            Reporter: Volodymyr Panivko
>            Assignee: Volodymyr Panivko
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Add a new HTTP client transport for the PHP library: 
> {{Thrift\Transport\TPsrHttpClient}}. Purely additive — existing 
> {{TCurlClient}} and {{THttpClient}} are untouched.
> *Design*
> * Constructor: {{(string $url, ?ClientInterface $client = null, 
> ?RequestFactoryInterface $requestFactory = null, ?StreamFactoryInterface 
> $streamFactory = null)}}.
> * Delegates all network I/O to a PSR-18 {{ClientInterface}}; PSR-7 messages 
> and PSR-17 factories handle request/URL construction. URL parsing, 
> port-suppression and percent-encoding are no longer hand-rolled.
> * When client / factories are omitted, {{php-http/discovery}} resolves them. 
> Discovery failures are wrapped as {{TTransportException::NOT_OPEN}} with an 
> actionable "Install one of: guzzlehttp/guzzle, symfony/http-client, 
> php-http/curl-client" message instead of an autoloader-level fatal.
> * PSR-7 {{\InvalidArgumentException}} and {{\RuntimeException}} from 
> {{createStream}}/{{createRequest}}/{{withHeader}} are wrapped as 
> {{TTransportException::NOT_OPEN}}. PSR-18 {{NetworkExceptionInterface}} maps 
> to {{NOT_OPEN}}, other {{ClientExceptionInterface}} subtypes and non-200 
> responses map to {{UNKNOWN}}.
> *Composer*
> * {{require}}: {{psr/http-client}}, {{psr/http-factory}}, 
> {{psr/http-message}}, {{php-http/discovery}}.
> * {{suggest}}: {{guzzlehttp/guzzle}}, {{symfony/http-client}}, 
> {{php-http/curl-client}}.
> * {{require-dev}}: {{nyholm/psr7}} for the unit-test suite.
> * {{config.allow-plugins}}: {{php-http/discovery}} explicitly allow-listed 
> (Composer 2.2+ requirement).
> *Tests*
> New {{TPsrHttpClientTest}} (15 cases) uses an injected fake 
> {{ClientInterface}} and real {{nyholm/psr7}} factories — no {{phpmock}} 
> required. Covers headers, URL pass-through, exception mapping (network, 
> client, invalid URL), empty body, buffer lifecycle, status codes.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to