diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-08-29 14:52:37 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-08-29 14:56:08 +0200 |
commit | b67d39508909e72913c97a050b25b51a9b1bd707 (patch) | |
tree | 9f40e8342c2208c34e92726dba6d3605abf249b7 /lib/private | |
parent | faa62d17993b9467f0041cbca2cafccdcb243385 (diff) | |
download | nextcloud-server-b67d39508909e72913c97a050b25b51a9b1bd707.tar.gz nextcloud-server-b67d39508909e72913c97a050b25b51a9b1bd707.zip |
allow streamed responses in http client
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/http/client/client.php | 3 | ||||
-rw-r--r-- | lib/private/http/client/response.php | 15 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/private/http/client/client.php b/lib/private/http/client/client.php index 323fc0d324f..b0aff10a413 100644 --- a/lib/private/http/client/client.php +++ b/lib/private/http/client/client.php @@ -120,7 +120,8 @@ class Client implements IClient { */ public function get($uri, array $options = []) { $response = $this->client->get($uri, $options); - return new Response($response); + $isStream = isset($options['stream']) && $options['stream']; + return new Response($response, $isStream); } /** diff --git a/lib/private/http/client/response.php b/lib/private/http/client/response.php index 4e9df51d77f..558482491d1 100644 --- a/lib/private/http/client/response.php +++ b/lib/private/http/client/response.php @@ -34,17 +34,26 @@ class Response implements IResponse { private $response; /** + * @var bool + */ + private $stream; + + /** * @param GuzzleResponse $response + * @param bool $stream */ - public function __construct(GuzzleResponse $response) { + public function __construct(GuzzleResponse $response, $stream = false) { $this->response = $response; + $this->stream = $stream; } /** - * @return string + * @return string|resource */ public function getBody() { - return $this->response->getBody()->getContents(); + return $this->stream ? + $this->response->getBody()->detach(): + $this->response->getBody()->getContents(); } /** |