Http client (psr-18), request and response object message interfaces (psr-7).

Installs: 25

Dependents: 2

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/inanepain/http

0.4.0 2026-02-19 23:33 UTC

This package is auto-updated.

Last update: 2026-02-19 23:40:40 UTC


README

Table of Contents

icon inanepain/http

Http client (psr-18), request and response object message interfaces (psr-7).

1. Install

Example 1. composer

composer require inanepain/http

2. Usage

$client = new \Inane\Http\Client();
$response = new \Inane\Http\Response();
$response->setBody('{"title":"Example"}');
$client->send($response);

2.1. Download Progress

How to show progress on downloads requested using the Http Client.

Print download progress to console.
class Package implements NotifyProgressInterface {
    public function progress(int $download_total, int $downloaded, int $percent): void {
        if ($percent === 100) {
            printf("\rDownloaded: %d bytes", $downloaded);
        } else {
            printf("\rDownloaded: %0.2f%% (%d / %d bytes)", $percent, $downloaded, $download_total);
        }
    }
}

$pkg = new Package('xxx');

$client = new \Inane\Http\Client();
$request = new Request('GET', $pkg->getDataUrl());

$client->registerProgressListener($pkg);

$response = $client->sendRequest($request);
$json = $response->getBody()->getContents();

3. Client Download Progress

How to show progress on downloads served using the Http Client.

// to be continued...