diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-23 09:10:53 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-24 21:30:39 +0200 |
commit | a1ed8207e9461929196340034b8c36265bd88776 (patch) | |
tree | e2fdddaae0a9ab3687d1f194057a53e044e85d23 /apps/files_sharing/lib/External | |
parent | 42ef33661f3dd5aee7b6ce0b0846b321273e3f45 (diff) | |
download | nextcloud-server-a1ed8207e9461929196340034b8c36265bd88776.tar.gz nextcloud-server-a1ed8207e9461929196340034b8c36265bd88776.zip |
HTTPHelper is deprecated
Use the IClientService instead
Diffstat (limited to 'apps/files_sharing/lib/External')
-rw-r--r-- | apps/files_sharing/lib/External/Manager.php | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 741428d8e88..0a57324c32f 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -32,6 +32,7 @@ namespace OCA\Files_Sharing\External; use OC\Files\Filesystem; use OCA\FederatedFileSharing\DiscoveryManager; use OCP\Files; +use OCP\Http\Client\IClientService; use OCP\Notification\IManager; class Manager { @@ -58,9 +59,9 @@ class Manager { private $storageLoader; /** - * @var \OC\HTTPHelper + * @var IClientService */ - private $httpHelper; + private $clientService; /** * @var IManager @@ -73,7 +74,7 @@ class Manager { * @param \OCP\IDBConnection $connection * @param \OC\Files\Mount\Manager $mountManager * @param \OCP\Files\Storage\IStorageFactory $storageLoader - * @param \OC\HTTPHelper $httpHelper + * @param IClientService $clientService * @param IManager $notificationManager * @param DiscoveryManager $discoveryManager * @param string $uid @@ -81,14 +82,14 @@ class Manager { public function __construct(\OCP\IDBConnection $connection, \OC\Files\Mount\Manager $mountManager, \OCP\Files\Storage\IStorageFactory $storageLoader, - \OC\HTTPHelper $httpHelper, + IClientService $clientService, IManager $notificationManager, DiscoveryManager $discoveryManager, $uid) { $this->connection = $connection; $this->mountManager = $mountManager; $this->storageLoader = $storageLoader; - $this->httpHelper = $httpHelper; + $this->clientService = $clientService; $this->uid = $uid; $this->notificationManager = $notificationManager; $this->discoveryManager = $discoveryManager; @@ -262,10 +263,23 @@ class Manager { $url = rtrim($remote, '/') . $this->discoveryManager->getShareEndpoint($remote) . '/' . $remoteId . '/' . $feedback . '?format=' . \OCP\Share::RESPONSE_FORMAT; $fields = array('token' => $token); - $result = $this->httpHelper->post($url, $fields); - $status = json_decode($result['result'], true); + $client = $this->clientService->newClient(); + + try { + $response = $client->post( + $url, + [ + 'body' => $fields, + 'connect_timeout' => 10, + ] + ); + } catch (\Exception $e) { + return false; + } + + $status = json_decode($response->getBody(), true); - return ($result['success'] && ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200)); + return ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200); } /** |