2017 © Pedro Peláez
 

library reactphp-http-client

Asynchronous HTTP client library.

image

werkint/reactphp-http-client

Asynchronous HTTP client library.

  • Monday, December 5, 2016
  • by nick4fake
  • Repository
  • 4 Watchers
  • 0 Stars
  • 1,442 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 58 Forks
  • 0 Open issues
  • 27 Versions
  • 0 % Grown

The README.md

HttpClient Component

Build Status Code Climate, (*1)

Basic HTTP/1.0 client., (*2)

Basic usage

Requests are prepared using the Client#request() method. Body can be sent with Request#write(). Request#end() finishes sending the request (or sends it at all if no body was written)., (*3)

Request implements WritableStreamInterface, so a Stream can be piped to it. Response implements ReadableStreamInterface., (*4)

Interesting events emitted by Request:, (*5)

  • response: The response headers were received from the server and successfully parsed. The first argument is a Response instance.
  • error: An error occurred.
  • end: The request is finished. If an error occurred, it is passed as first argument. Second and third arguments are the Response and the Request.

Interesting events emitted by Response:, (*6)

  • data: Passes a chunk of the response body as first argument and a Response object itself as second argument. When a response encounters a chunked encoded response it will parse it transparently for the user of Response and removing the Transfer-Encoding header.
  • error: An error occurred.
  • end: The response has been fully received. If an error occurred, it is passed as first argument.

Example

<?php

$loop = React\EventLoop\Factory::create();

$dnsResolverFactory = new React\Dns\Resolver\Factory();
$dnsResolver = $dnsResolverFactory->createCached('8.8.8.8', $loop);

$factory = new React\HttpClient\Factory();
$client = $factory->create($loop, $dnsResolver);

$request = $client->request('GET', 'https://github.com/');
$request->on('response', function ($response) {
    $response->on('data', function ($data, $response) {
        // ...
    });
});
$request->end();
$loop->run();

See also the examples., (*7)

TODO

  • gzip content encoding
  • keep-alive connections
  • following redirections

The Versions

13/09 2016

dev-feature-chunked-encoding

dev-feature-chunked-encoding

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http

24/03 2016

0.3.x-dev

0.3.9999999.9999999-dev

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http

24/03 2016

v0.3.2

0.3.2.0

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http

16/06 2015
15/06 2015
14/05 2015
23/11 2014
01/06 2014

dev-compat-parser-deps

dev-compat-parser-deps

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http

02/02 2014

v0.4.0

0.4.0.0

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http

21/04 2013

v0.3.1

0.3.1.0

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http

14/04 2013

v0.3.0

0.3.0.0

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http

26/12 2012

v0.2.6

0.2.6.0

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http

26/11 2012

v0.2.5

0.2.5.0

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http

05/11 2012

v0.2.3

0.2.3.0

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http

28/10 2012

v0.2.2

0.2.2.0

Asynchronous HTTP client library.

  Sources   Download

MIT

The Requires

 

http