private function getSaveToBody(
        RequestInterface $request,
        StreamInterface $stream
    ) {
        if ($saveTo = $request->getConfig()['save_to']) {
            // Stream the response into the destination stream
            $saveTo = is_string($saveTo)
                ? new Stream(Utils::open($saveTo, 'r+'))
                : Stream::factory($saveTo);
        } else {
            // Stream into the default temp stream
            $saveTo = Stream::factory();
        }

        Utils::copyToStream($stream, $saveTo);
        $saveTo->seek(0);
        $stream->close();

        return $saveTo;
    }
private function getSaveToBody(
        RequestInterface $request,
        StreamInterface $stream
    ) {
        if ($saveTo = $request->getConfig()['save_to']) {
            // Stream the response into the destination stream
            $saveTo = is_string($saveTo)
                ? new Stream(Utils::open($saveTo, 'r+'))
                : Stream::factory($saveTo);
        } else {
            // Stream into the default temp stream
            $saveTo = Stream::factory();
        }

        Utils::copyToStream($stream, $saveTo);
        $saveTo->seek(0);
        $stream->close();

        return $saveTo;
    }
private function getSaveToBody ( RequestInterface $ request , StreamInterface $ stream ) { if ( $ saveTo = $ request -> getConfig ( ) [ 'save_to' ] ) { // Stream the response into the destination stream $ saveTo = is_string ( $ saveTo ) ? new Stream ( Utils :: open ( $ saveTo , 'r+' ) ) : Stream :: factory ( $ saveTo ) ; } else { // Stream into the default temp stream $ saveTo = Stream :: factory ( ) ; } Utils :: copyToStream ( $ stream , $ saveTo ) ; $ saveTo -> seek ( 0 ) ; $ stream -> close ( ) ; return $ saveTo ; }
Drain the stream into the destination stream
Drain the stream into the destination stream