Skip to content

Conversation

@arnaud-lb
Copy link
Contributor

Currently, HttpClient\Request isn't a well-behaved WritableStreamInterface: write() can return false (telling the user to stop writing to it until it emits a drain event), but there are cases where it never emits a drain event: When calling write() before the headers have been sent, write() returns false and actually writes the body later. However, it doesn't emit a drain event.

This is a problem, for instance, when using pipe():

$request = $client->request("POST", "http://example.com");
Util::pipe($readableStream, $request);

pipe() will pause $readableStream when $request->write() returns false, and resume $readableStream when $request emits a drain event. If $request never emits a drain event, the pipe operation never finishes.

This PR fixes that by emitting a drain event when the request is ready to receive more write() calls.

@WyriHaximus
Copy link
Member

Hey thank you for your PR, sounds and looks good at first glance. Going to review it and come back to you later 👍

@clue
Copy link
Member

clue commented Jun 14, 2015

Changes LGTM 👍

@WyriHaximus
Copy link
Member

@clue thanks!

@arnaud-lb My apologise for the delay, things didn't go as planned and I'll go over this PR and merge and tag it tomorrow when I don't find anything with it :)

WyriHaximus added a commit that referenced this pull request Jun 16, 2015
Emit drain event when the request is ready to receive more data
@WyriHaximus WyriHaximus merged commit 391e1e7 into reactphp:master Jun 16, 2015
@WyriHaximus
Copy link
Member

Thanks again for the PR, I'll tag it shortly

@arnaud-lb
Copy link
Contributor Author

Thanks @WyriHaximus @clue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants