WyriHaximus / react-guzzle-http-client

Meta package for ReactPHP HttpClient adapters/handles for Guzzle 4, 5, and 6.
MIT License
10 stars 8 forks source link

Guzzle's Sink Request Option Does Not Write To File #3

Open shaunbramley opened 8 years ago

shaunbramley commented 8 years ago

In Guzzle 6.x, the save_to request option was deprecated in favor of sink. While GuzzleHttp\Client will accept save_to; it is mapped internally to sink within Client::transfer() prior to calling the handler.

Option handling within WyriHaximus\React\Guzzle\HttpClient\Request does not support sink.

$loop = React\EventLoop\Factory::create();
$handler = new WyriHaximus\React\GuzzlePsr7\HttpClientAdapter($loop);

$client = new GuzzleHttp\Client([
    'handler' => \GuzzleHttp\HandlerStack::create($handler),
    'debug' => true,
    'sink' => 'file.txt',

]);

$start = time();

$client->getAsync('http://www.google.com')->then(function ($response) use ($start) {
    printf('%d s have elapsed end of request'. PHP_EOL, time() - $start);
});

$loop->run();

printf('%d s have elapsed - end of application' . PHP_EOL, time() - $start);

This code sample will result in no file being created.

Expected output: 'file.txt' containing the response body of the http request.