summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-03-26 11:06:48 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-03-26 11:06:48 +0100
commit20f5290462cddee766025bd5671430836b054cc8 (patch)
treea0b33a654f6fa2ed4c75dffd9f65ddd437ada90f /apps/files_sharing
parentc8f0cbab5a994aadfaa9c984bb9959ca872fe781 (diff)
parent5f044ebf1bc6f45acec2e79dc05185acd0405f42 (diff)
downloadnextcloud-server-20f5290462cddee766025bd5671430836b054cc8.tar.gz
nextcloud-server-20f5290462cddee766025bd5671430836b054cc8.zip
Merge pull request #15195 from owncloud/reanimate-add-guzzle
Add wrapper for Guzzle
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/controllers/sharecontroller.php2
-rw-r--r--apps/files_sharing/lib/external/storage.php36
-rw-r--r--apps/files_sharing/tests/server2server.php4
3 files changed, 15 insertions, 27 deletions
diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php
index 2f69583b412..f9b85913a08 100644
--- a/apps/files_sharing/lib/controllers/sharecontroller.php
+++ b/apps/files_sharing/lib/controllers/sharecontroller.php
@@ -11,6 +11,7 @@
namespace OCA\Files_Sharing\Controllers;
+use Hoa\Core\Data\Data;
use OC;
use OC\Files\Filesystem;
use OC_Files;
@@ -30,6 +31,7 @@ use OCA\Files_Sharing\Helper;
use OCP\User;
use OCP\Util;
use OCA\Files_Sharing\Activity;
+use OCP\AppFramework\Http\DataResponse;
/**
* Class ShareController
diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php
index 51c4a36029e..ade789e310a 100644
--- a/apps/files_sharing/lib/external/storage.php
+++ b/apps/files_sharing/lib/external/storage.php
@@ -210,37 +210,23 @@ class Storage extends DAV implements ISharedStorage {
}
}
+ /**
+ * @return mixed
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws \Exception
+ */
public function getShareInfo() {
$remote = $this->getRemote();
$token = $this->getToken();
$password = $this->getPassword();
$url = rtrim($remote, '/') . '/index.php/apps/files_sharing/shareinfo?t=' . $token;
- $ch = curl_init();
-
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS,
- http_build_query(array('password' => $password)));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
- $path = $this->certificateManager->getCertificateBundle();
- if (is_readable($path)) {
- curl_setopt($ch, CURLOPT_CAINFO, $path);
- }
-
- $result = curl_exec($ch);
-
- $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- $errorMessage = curl_error($ch);
- curl_close($ch);
- if (!empty($errorMessage)) {
- throw new \Exception($errorMessage);
- }
+ // TODO: DI
+ $client = \OC::$server->getHTTPClientService()->newClient();
+ $response = $client->post($url, ['body' => ['password' => $password]]);
- switch ($status) {
+ switch ($response->getStatusCode()) {
case 401:
case 403:
throw new ForbiddenException();
@@ -250,6 +236,6 @@ class Storage extends DAV implements ISharedStorage {
throw new \Exception();
}
- return json_decode($result, true);
+ return json_decode($response->getBody(), true);
}
}
diff --git a/apps/files_sharing/tests/server2server.php b/apps/files_sharing/tests/server2server.php
index 6e9c0dd0ddd..f582be3a86a 100644
--- a/apps/files_sharing/tests/server2server.php
+++ b/apps/files_sharing/tests/server2server.php
@@ -48,9 +48,9 @@ class Test_Files_Sharing_S2S_OCS_API extends TestCase {
$config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock();
- $certificateManager = $this->getMock('\OCP\ICertificateManager');
+ $clientService = $this->getMock('\OCP\Http\Client\IClientService');
$httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
- ->setConstructorArgs(array($config, $certificateManager))
+ ->setConstructorArgs([$config, $clientService])
->getMock();
$httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true));