summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/http/client/client.php3
-rw-r--r--lib/private/http/client/response.php15
-rw-r--r--lib/public/http/client/iresponse.php2
3 files changed, 15 insertions, 5 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();
}
/**
diff --git a/lib/public/http/client/iresponse.php b/lib/public/http/client/iresponse.php
index 0e0ef4c5014..92bb7af82dd 100644
--- a/lib/public/http/client/iresponse.php
+++ b/lib/public/http/client/iresponse.php
@@ -30,7 +30,7 @@ namespace OCP\Http\Client;
*/
interface IResponse {
/**
- * @return string
+ * @return string|resource
* @since 8.1.0
*/
public function getBody();