summaryrefslogtreecommitdiffstats
path: root/lib/private/http
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-09-11 17:10:10 +0200
committerLukas Reschke <lukas@owncloud.com>2015-09-11 17:10:10 +0200
commit1924dd348a41bb52968f4fe598dd6f170536c724 (patch)
treebbe3748db0af564a886b77969309525072c7123b /lib/private/http
parent0468a7dfd4379a2ab557a66d0b8ac2a01336f4ab (diff)
parent1c10fb5c9f583d562184097fd2fd97e1b121773f (diff)
downloadnextcloud-server-1924dd348a41bb52968f4fe598dd6f170536c724.tar.gz
nextcloud-server-1924dd348a41bb52968f4fe598dd6f170536c724.zip
Merge pull request #18653 from owncloud/dav-stream-guzzle
stream webdav downloads using http client
Diffstat (limited to 'lib/private/http')
-rw-r--r--lib/private/http/client/client.php3
-rw-r--r--lib/private/http/client/response.php15
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();
}
/**