diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php | 2 | ||||
-rw-r--r-- | apps/federatedfilesharing/lib/RequestHandler.php | 2 | ||||
-rw-r--r-- | apps/federatedfilesharing/tests/RequestHandlerTest.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/API/Remote.php | 12 | ||||
-rw-r--r-- | apps/files_sharing/lib/AppInfo/Application.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Manager.php | 30 | ||||
-rw-r--r-- | apps/files_sharing/lib/Hooks.php | 2 |
7 files changed, 33 insertions, 19 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php index 93ccafb001c..55329338a92 100644 --- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php +++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php @@ -242,7 +242,7 @@ class MountPublicLinkController extends Controller { \OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), - \OC::$server->getHTTPHelper(), + \OC::$server->getHTTPClientService(), \OC::$server->getNotificationManager(), $discoveryManager, \OC::$server->getUserSession()->getUser()->getUID() diff --git a/apps/federatedfilesharing/lib/RequestHandler.php b/apps/federatedfilesharing/lib/RequestHandler.php index 1870b03665b..f531c7bcb4a 100644 --- a/apps/federatedfilesharing/lib/RequestHandler.php +++ b/apps/federatedfilesharing/lib/RequestHandler.php @@ -147,7 +147,7 @@ class RequestHandler { \OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), - \OC::$server->getHTTPHelper(), + \OC::$server->getHTTPClientService(), \OC::$server->getNotificationManager(), $discoveryManager, $shareWith diff --git a/apps/federatedfilesharing/tests/RequestHandlerTest.php b/apps/federatedfilesharing/tests/RequestHandlerTest.php index 9689716af3d..8f9f1384184 100644 --- a/apps/federatedfilesharing/tests/RequestHandlerTest.php +++ b/apps/federatedfilesharing/tests/RequestHandlerTest.php @@ -250,7 +250,7 @@ class RequestHandlerTest extends TestCase { \OC::$server->getDatabaseConnection(), Filesystem::getMountManager(), Filesystem::getLoader(), - \OC::$server->getHTTPHelper(), + \OC::$server->getHTTPClientService(), \OC::$server->getNotificationManager(), $discoveryManager, $toDelete 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']); |