summaryrefslogtreecommitdiffstats
path: root/lib/private/files/storage/dav.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-08-29 14:53:59 +0200
committerRobin Appelman <icewind@owncloud.com>2015-08-29 14:56:15 +0200
commitdf8cb2cc638bdd8fe0c82604b4347502b2fdb1c3 (patch)
tree2e42e701807abdc1a9dd24ff6e89297154134bb1 /lib/private/files/storage/dav.php
parentb67d39508909e72913c97a050b25b51a9b1bd707 (diff)
downloadnextcloud-server-df8cb2cc638bdd8fe0c82604b4347502b2fdb1c3.tar.gz
nextcloud-server-df8cb2cc638bdd8fe0c82604b4347502b2fdb1c3.zip
stream webdav downloads using http client
Diffstat (limited to 'lib/private/files/storage/dav.php')
-rw-r--r--lib/private/files/storage/dav.php44
1 files changed, 15 insertions, 29 deletions
diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php
index 6e89dcccbcd..2b6262f3720 100644
--- a/lib/private/files/storage/dav.php
+++ b/lib/private/files/storage/dav.php
@@ -40,6 +40,7 @@ use OC\Files\Filesystem;
use OC\Files\Stream\Close;
use Icewind\Streams\IteratorDirectory;
use OC\MemCache\ArrayCache;
+use OCP\AppFramework\Http;
use OCP\Constants;
use OCP\Files;
use OCP\Files\FileInfo;
@@ -337,38 +338,23 @@ class DAV extends Common {
if (!$this->file_exists($path)) {
return false;
}
- //straight up curl instead of sabredav here, sabredav put's the entire get result in memory
- $curl = curl_init();
- $fp = fopen('php://temp', 'r+');
- curl_setopt($curl, CURLOPT_USERPWD, $this->user . ':' . $this->password);
- curl_setopt($curl, CURLOPT_URL, $this->createBaseUri() . $this->encodePath($path));
- curl_setopt($curl, CURLOPT_FILE, $fp);
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
- if(defined('CURLOPT_PROTOCOLS')) {
- curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
- }
- if(defined('CURLOPT_REDIR_PROTOCOLS')) {
- curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
- }
- if ($this->secure === true) {
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
- if ($this->certPath) {
- curl_setopt($curl, CURLOPT_CAINFO, $this->certPath);
- }
- }
-
- curl_exec($curl);
- $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
- if ($statusCode !== 200) {
- Util::writeLog("webdav client", 'curl GET ' . curl_getinfo($curl, CURLINFO_EFFECTIVE_URL) . ' returned status code ' . $statusCode, Util::ERROR);
- if ($statusCode === 423) {
+ $httpClient = \OC::$server->getHTTPClientService();
+ $response = $httpClient
+ ->newClient()
+ ->get($this->createBaseUri() . $this->encodePath($path), [
+ 'auth' => [$this->user, $this->password],
+ 'stream' => true
+ ]);
+
+ if ($response->getStatusCode() !== Http::STATUS_OK) {
+ if ($response->getStatusCode() === Http::STATUS_LOCKED) {
throw new \OCP\Lock\LockedException($path);
+ } else {
+ Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), Util::ERROR);
}
}
- curl_close($curl);
- rewind($fp);
- return $fp;
+
+ return $response->getBody();
case 'w':
case 'wb':
case 'a':