PHPackages                             werkint/reactphp-http-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. werkint/reactphp-http-client

Abandoned → [werkint/reactphp-http-client](/?search=werkint%2Freactphp-http-client)Library[HTTP &amp; Networking](/categories/http)

werkint/reactphp-http-client
============================

Asynchronous HTTP client library.

v0.4.14(9y ago)01.5kMITPHPPHP &gt;=5.4.0

Since Oct 28Pushed 9y ago4 watchersCompare

[ Source](https://github.com/Werkint/http-client)[ Packagist](https://packagist.org/packages/werkint/reactphp-http-client)[ RSS](/packages/werkint-reactphp-http-client/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (7)Versions (27)Used By (0)

HttpClient Component
====================

[](#httpclient-component)

[![Build Status](https://camo.githubusercontent.com/49134becfbef8f821c3de02dfe0020850b315437cfd58efb0fe17efcec5a6675/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f72656163747068702f687474702d636c69656e742e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/reactphp/http-client) [![Code Climate](https://camo.githubusercontent.com/d59d0afc7e77e0b0a38f2d137a7d1ad42ffec02b0fe3424180bd099eafd78099/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f72656163747068702f687474702d636c69656e742f6261646765732f6770612e737667)](https://codeclimate.com/github/reactphp/http-client)

Basic HTTP/1.0 client.

Basic usage
-----------

[](#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).

Request implements WritableStreamInterface, so a Stream can be piped to it. Response implements ReadableStreamInterface.

Interesting events emitted by Request:

- `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:

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

[](#example)

```
