Documentation

DecoderPlugin
in package
implements Plugin

FinalYes

Allow to decode response body with a chunk, deflate, compress or gzip encoding.

If zlib is not installed, only chunked encoding can be handled.

If Content-Encoding is not disabled, the plugin will add an Accept-Encoding header for the encoding methods it supports.

Tags
author

Joel Wurtz joel.wurtz@gmail.com

Table of Contents

Interfaces

Plugin
A plugin is a middleware to transform the request and/or the response.

Properties

$useContentEncoding  : bool

Methods

__construct()  : mixed
handleRequest()  : Promise
Handle the request and return the response coming from the next callable.
decodeOnEncodingHeader()  : ResponseInterface
Decode a response on a specific header (content encoding or transfer encoding mainly).
decodeResponse()  : ResponseInterface
Decode a response body given its Transfer-Encoding or Content-Encoding value.
decorateStream()  : StreamInterface|false
Decorate a stream given an encoding.

Properties

$useContentEncoding

private bool $useContentEncoding

Whether this plugin decode stream with value in the Content-Encoding header (default to true).

If set to false only the Transfer-Encoding header will be used

Methods

__construct()

public __construct([array{'use_content_encoding'?: bool} $config = [] ]) : mixed
Parameters
$config : array{'use_content_encoding'?: bool} = []

Configuration options:

  • use_content_encoding: Whether this plugin should look at the Content-Encoding header first or only at the Transfer-Encoding (defaults to true)

handleRequest()

Handle the request and return the response coming from the next callable.

public handleRequest(RequestInterface $request, callable $next, callable $first) : Promise
Parameters
$request : RequestInterface
$next : callable

Next middleware in the chain, the request is passed as the first argument

$first : callable

First middleware in the chain, used to to restart a request

Return values
Promise

Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient)


        
On this page

Search results