summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-08-23 09:10:53 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-08-24 21:30:39 +0200
commita1ed8207e9461929196340034b8c36265bd88776 (patch)
treee2fdddaae0a9ab3687d1f194057a53e044e85d23 /apps/files_sharing
parent42ef33661f3dd5aee7b6ce0b0846b321273e3f45 (diff)
downloadnextcloud-server-a1ed8207e9461929196340034b8c36265bd88776.tar.gz
nextcloud-server-a1ed8207e9461929196340034b8c36265bd88776.zip
HTTPHelper is deprecated
Use the IClientService instead
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/API/Remote.php12
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php2
-rw-r--r--apps/files_sharing/lib/External/Manager.php30
-rw-r--r--apps/files_sharing/lib/Hooks.php2
4 files changed, 30 insertions, 16 deletions
diff --git a/apps/files_sharing/lib/API/Remote.php b/apps/files_sharing/lib/API/Remote.php
index c641899da93..a522f923a39 100644
--- a/apps/files_sharing/lib/API/Remote.php
+++ b/apps/files_sharing/lib/API/Remote.php
@@ -45,7 +45,7 @@ class Remote {
\OC::$server->getDatabaseConnection(),
Filesystem::getMountManager(),
Filesystem::getLoader(),
- \OC::$server->getHTTPHelper(),
+ \OC::$server->getHTTPClientService(),
\OC::$server->getNotificationManager(),
$discoveryManager,
\OC_User::getUser()
@@ -69,7 +69,7 @@ class Remote {
\OC::$server->getDatabaseConnection(),
Filesystem::getMountManager(),
Filesystem::getLoader(),
- \OC::$server->getHTTPHelper(),
+ \OC::$server->getHTTPClientService(),
\OC::$server->getNotificationManager(),
$discoveryManager,
\OC_User::getUser()
@@ -100,7 +100,7 @@ class Remote {
\OC::$server->getDatabaseConnection(),
Filesystem::getMountManager(),
Filesystem::getLoader(),
- \OC::$server->getHTTPHelper(),
+ \OC::$server->getHTTPClientService(),
\OC::$server->getNotificationManager(),
$discoveryManager,
\OC_User::getUser()
@@ -148,7 +148,7 @@ class Remote {
\OC::$server->getDatabaseConnection(),
Filesystem::getMountManager(),
Filesystem::getLoader(),
- \OC::$server->getHTTPHelper(),
+ \OC::$server->getHTTPClientService(),
\OC::$server->getNotificationManager(),
$discoveryManager,
\OC_User::getUser()
@@ -176,7 +176,7 @@ class Remote {
\OC::$server->getDatabaseConnection(),
Filesystem::getMountManager(),
Filesystem::getLoader(),
- \OC::$server->getHTTPHelper(),
+ \OC::$server->getHTTPClientService(),
\OC::$server->getNotificationManager(),
$discoveryManager,
\OC_User::getUser()
@@ -207,7 +207,7 @@ class Remote {
\OC::$server->getDatabaseConnection(),
Filesystem::getMountManager(),
Filesystem::getLoader(),
- \OC::$server->getHTTPHelper(),
+ \OC::$server->getHTTPClientService(),
\OC::$server->getNotificationManager(),
$discoveryManager,
\OC_User::getUser()
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index b9598bd4a2b..0e70924da40 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -105,7 +105,7 @@ class Application extends App {
$server->getDatabaseConnection(),
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
- $server->getHTTPHelper(),
+ $server->getHTTPClientService(),
$server->getNotificationManager(),
$discoveryManager,
$uid
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);
}
/**
diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php
index 237e845bc4e..2029e97d08b 100644
--- a/apps/files_sharing/lib/Hooks.php
+++ b/apps/files_sharing/lib/Hooks.php
@@ -40,7 +40,7 @@ class Hooks {
\OC::$server->getDatabaseConnection(),
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
- \OC::$server->getHTTPHelper(),
+ \OC::$server->getHTTPClientService(),
\OC::$server->getNotificationManager(),
$discoveryManager,
$params['uid']);