webclient/ext-protocol-version

Auto change protocol version extension for PSR-18 HTTP client

v2.0.0 2022-07-22 14:38 UTC

This package is auto-updated.

Last update: 2024-12-22 19:58:15 UTC


README

Latest Stable Version Total Downloads License PHP

webclient/ext-protocol-version

Auto change protocol version extension for PSR-18 HTTP client.

Install

Install this package and your favorite psr-18 implementation.

composer require webclient/ext-protocol-version:^2.0

Using

<?php

use Webclient\Extension\ProtocolVersion\ProtocolClientDecorator;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;

/** 
 * @var ClientInterface $client Your PSR-18 HTTP Client
 */
$http = new ProtocolClientDecorator($client);

/** @var RequestInterface $request */
$response = $http->sendRequest($request);

If server returns a 505 error, this client will repeat the request with the protocol version specified in the server response.