Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify acessing response body #48

Closed
clue opened this issue Sep 21, 2015 · 7 comments
Closed

Simplify acessing response body #48

clue opened this issue Sep 21, 2015 · 7 comments

Comments

@clue
Copy link
Member

clue commented Sep 21, 2015

Accessing the HTTP response body is likely one of the main use cases for this library, however it's actually unnecessarily cumbersome.

This has come up several times already, so we way want to look into providing a simpler API.

Possibly related to #41.

@WyriHaximus
Copy link
Member

While try I like to keep streaming without storing data posssible, maybe #29 is a way to achieve this? Now the question is which one do we want to be the default. I personally think that easy access to the response body should be the default, and streaming it in should be a secondary option

@clue
Copy link
Member Author

clue commented Mar 10, 2017

This likely depends on #70 in order to fix stream semantics first.

We may then provide normal stream buffering routines and should probably add an example here.

Once this is in, we may want to look into #41 to implement PSR-7 message body support.

@clue
Copy link
Member Author

clue commented Feb 23, 2018

Minor progress update: #70 has been implemented, which means that one can now use ReactPHP's normal stream primitives to buffer the whole request body:

$request = $client->request('GET', 'https://google.com/');
$request->on('response', function (Response $response) {
    \React\Promise\Stream\buffer($response)->then(function ($body) {
        echo $body;
    }, 'printf');
});
$request->end();

We're still working on a simpler API for #41 👍

@slince
Copy link

slince commented Feb 27, 2018

@clue It seems the function \React\Promise\Stream\buffer is not exists. .

@jsor
Copy link
Member

jsor commented Feb 27, 2018

@slince This function is from the react/promise-stream package.

composer req react/promise-stream

@slince
Copy link

slince commented Feb 27, 2018

@jsor thks

@clue
Copy link
Member Author

clue commented Jul 13, 2020

I'm closing this as it is already supported by the new HTTP client that has been merged into react/http via reactphp/http#368 :shipit: You should upgrade as per #152 👍

@clue clue closed this as completed Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants