webclient/ext-redirect

PSR-18 HTTP客户端的重定向扩展

v2.0.0 2022-07-21 16:34 UTC

This package is auto-updated.

Last update: 2024-09-21 21:06:54 UTC


README

Latest Stable Version Total Downloads License PHP

webclient/ext-redirect

PSR-18 HTTP客户端的重定向扩展。

安装

安装此包以及您喜欢的 psr-18 实现

composer require webclient/ext-redirect:^2.0

使用

<?php

use Webclient\Extension\Redirect\RedirectClientDecorator;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;

/** 
 * @var ClientInterface $client Your PSR-18 HTTP Client
 * @var int $maxRedirects Max follow redirects
 */
$http = new RedirectClientDecorator($client, $maxRedirects);

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