puff/http-client

Fiber-aware PSR-18 HTTP client for PHP Unison Fiber Framework

Maintainers

Package info

github.com/php-puff/http-client

pkg:composer/puff/http-client

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

dev-main 2026-08-21 13:30 UTC

This package is auto-updated.

Last update: 2026-08-21 13:31:54 UTC


README

puff/http-client is a Fiber-aware PSR-18 HTTP/1.1 client implemented with native non-blocking PHP streams. It does not require cURL. TCP and TLS transport are provided by puff/client.

composer require puff/http-client

Configuration

The package publishes config/http.client.php. Puff derives the configuration path from the filename, so its values are available under http.client:

return [
    'connect_timeout' => 10.0,
    'timeout' => 30.0,
    'max_redirects' => 5,
    'retries' => 0,
    'max_header_size' => 65536,
    'max_body_size' => 10485760,
];

A future puff/mqtt-client package should publish config/mqtt.client.php; that file maps independently to mqtt.client. Each protocol package owns its own configuration.

Synchronous PSR-18 usage

use Puff\Http\Factory\RequestFactory;
use Puff\HttpClient\HttpClient;

$request = (new RequestFactory())->createRequest('GET', 'https://example.com/');
$response = (new HttpClient())->sendRequest($request);

echo $response->getStatusCode();
echo (string) $response->getBody();

Asynchronous usage

$pending = $client->sendAsync($request);

// Do other event-loop work, or cancel when the result is no longer needed.
// $pending->cancel();

$response = $pending->await();

The client supports validated TLS, partial stream reads/writes, Content-Length, chunked responses, EOF-delimited bodies, redirects, cancellation, idempotent retries, response limits, and idle HTTP/1.1 connection reuse. HTTP pipelining is intentionally not used.