Skip to content

Auto change protocol version extension for PSR-18 HTTP client

License

Notifications You must be signed in to change notification settings

phpwebclient/ext-protocol-version

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.