Skip to content
/ http Public

Http client, request and response objects implementing psr-7 (message interfaces).

License

Unlicense, Unlicense licenses found

Licenses found

Unlicense
LICENSE
Unlicense
UNLICENSE
Notifications You must be signed in to change notification settings

inanepain/http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inanepain/http icon

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...

About

Http client, request and response objects implementing psr-7 (message interfaces).

Topics

Resources

License

Unlicense, Unlicense licenses found

Licenses found

Unlicense
LICENSE
Unlicense
UNLICENSE

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages