Skip to content

Commit

Permalink
Merge branch 'master' into response-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
hiend committed May 18, 2015
2 parents 1dee2a2 + 893b7c1 commit 8ac632b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ php:
- 5.4
- 5.5
- 5.6
- 7
- hhvm
- hhvm-nightly

matrix:
allow_failures:
- php: 7
- php: hhvm
- php: hhvm-nightly

before_script:
- composer install --dev --prefer-source
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HttpClient Component

[![Build Status](https://secure.travis-ci.org/reactphp/http-client.png?branch=master)](http://travis-ci.org/reactphp/http-client)
[![Build Status](https://secure.travis-ci.org/reactphp/http-client.png?branch=master)](http://travis-ci.org/reactphp/http-client) [![Code Climate](https://codeclimate.com/github/reactphp/http-client/badges/gpa.svg)](https://codeclimate.com/github/reactphp/http-client)

Basic HTTP/1.0 client.

Expand All @@ -17,16 +17,17 @@ 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 occured.
* `end`: The request is finished. If an error occured, it is passed as first
* `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
* `error`: An error occured.
* `data`: Passes a chunk of the response body as first argument and a Response
object itself as second argument.
* `error`: An error occurred.
* `end`: The response has been fully received. If an error
occured, it is passed as first argument
occurred, it is passed as first argument.

### Example

Expand All @@ -43,7 +44,7 @@ $client = $factory->create($loop, $dnsResolver);

$request = $client->request('GET', 'https://github.com/');
$request->on('response', function ($response) {
$response->on('data', function ($data) {
$response->on('data', function ($data, $response) {
// ...
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function handleData($data)

$this->emit('response', array($response, $this));

$response->emit('data', array($bodyChunk));
$response->emit('data', array($bodyChunk, $response));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use React\Stream\WritableStreamInterface;

/**
* @event data
* @event data ($bodyChunk, Response $thisResponse)
* @event error
* @event end
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function requestShouldBindToStreamEventsAndUseconnector()

$response->expects($this->once())
->method('emit')
->with('data', array('body'));
->with('data', array('body', $response));

$response->expects($this->at(0))
->method('on')
Expand Down

0 comments on commit 8ac632b

Please sign in to comment.