diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-03-13 16:30:41 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-03-13 21:54:56 +0100 |
commit | 7785c3752fbfef792cd33dc5da2ee63e8263b9fa (patch) | |
tree | 66b68c5f9ce30ec87c51aebc7d9ffe0c14b30d2f /lib | |
parent | ede723f1b19c4c1afb7627af85c1e2f8d8a31386 (diff) | |
download | nextcloud-server-7785c3752fbfef792cd33dc5da2ee63e8263b9fa.tar.gz nextcloud-server-7785c3752fbfef792cd33dc5da2ee63e8263b9fa.zip |
Remove deprecated HTTPHelper
* Remove the HTTP Helper
* Remove from Server Containter
* Removed legacy share tests that use it
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/private/HTTPHelper.php | 120 | ||||
-rw-r--r-- | lib/private/Server.php | 17 | ||||
-rw-r--r-- | lib/private/Share/Share.php | 17 | ||||
-rw-r--r-- | lib/public/IServerContainer.php | 8 |
6 files changed, 16 insertions, 148 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index fb699e35a61..49e07179483 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -696,7 +696,6 @@ return array( 'OC\\Group\\Group' => $baseDir . '/lib/private/Group/Group.php', 'OC\\Group\\Manager' => $baseDir . '/lib/private/Group/Manager.php', 'OC\\Group\\MetaData' => $baseDir . '/lib/private/Group/MetaData.php', - 'OC\\HTTPHelper' => $baseDir . '/lib/private/HTTPHelper.php', 'OC\\HintException' => $baseDir . '/lib/private/HintException.php', 'OC\\Hooks\\BasicEmitter' => $baseDir . '/lib/private/Hooks/BasicEmitter.php', 'OC\\Hooks\\Emitter' => $baseDir . '/lib/private/Hooks/Emitter.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 40b9c6237f0..d876cf0e23f 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -726,7 +726,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Group\\Group' => __DIR__ . '/../../..' . '/lib/private/Group/Group.php', 'OC\\Group\\Manager' => __DIR__ . '/../../..' . '/lib/private/Group/Manager.php', 'OC\\Group\\MetaData' => __DIR__ . '/../../..' . '/lib/private/Group/MetaData.php', - 'OC\\HTTPHelper' => __DIR__ . '/../../..' . '/lib/private/HTTPHelper.php', 'OC\\HintException' => __DIR__ . '/../../..' . '/lib/private/HintException.php', 'OC\\Hooks\\BasicEmitter' => __DIR__ . '/../../..' . '/lib/private/Hooks/BasicEmitter.php', 'OC\\Hooks\\Emitter' => __DIR__ . '/../../..' . '/lib/private/Hooks/Emitter.php', diff --git a/lib/private/HTTPHelper.php b/lib/private/HTTPHelper.php deleted file mode 100644 index d58f81fbbdc..00000000000 --- a/lib/private/HTTPHelper.php +++ /dev/null @@ -1,120 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Björn Schießle <bjoern@schiessle.org> - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OC; - -use OCP\Http\Client\IClientService; -use OCP\IConfig; - -/** - * Class HTTPHelper - * - * @package OC - * @deprecated Use \OCP\Http\Client\IClientService - */ -class HTTPHelper { - const USER_AGENT = 'ownCloud Server Crawler'; - - /** @var \OCP\IConfig */ - private $config; - /** @var IClientService */ - private $clientService; - - /** - * @param IConfig $config - * @param IClientService $clientService - */ - public function __construct(IConfig $config, - IClientService $clientService) { - $this->config = $config; - $this->clientService = $clientService; - } - - /** - * Get URL content - * @param string $url Url to get content - * @throws \Exception If the URL does not start with http:// or https:// - * @return string of the response or false on error - * This function get the content of a page via curl, if curl is enabled. - * If not, file_get_contents is used. - * @deprecated Use \OCP\Http\Client\IClientService - */ - public function getUrlContent($url) { - try { - $client = $this->clientService->newClient(); - $response = $client->get($url); - return $response->getBody(); - } catch (\Exception $e) { - return false; - } - } - - /** - * Returns the response headers of a HTTP URL without following redirects - * @param string $location Needs to be a HTTPS or HTTP URL - * @return array - * @deprecated Use \OCP\Http\Client\IClientService - */ - public function getHeaders($location) { - $client = $this->clientService->newClient(); - $response = $client->get($location); - return $response->getHeaders(); - } - - /** - * Checks whether the supplied URL begins with HTTPS:// or HTTP:// (case insensitive) - * @param string $url - * @return bool - */ - public function isHTTPURL($url) { - return stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0; - } - - /** - * send http post request - * - * @param string $url - * @param array $fields data send by the request - * @return array - * @deprecated Use \OCP\Http\Client\IClientService - */ - public function post($url, array $fields) { - $client = $this->clientService->newClient(); - - try { - $response = $client->post( - $url, - [ - 'body' => $fields, - 'connect_timeout' => 10, - ] - ); - } catch (\Exception $e) { - return ['success' => false, 'result' => $e->getMessage()]; - } - - return ['success' => true, 'result' => $response->getBody()]; - } - -} diff --git a/lib/private/Server.php b/lib/private/Server.php index af739c91b02..09807b185da 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -630,13 +630,6 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerAlias('DatabaseConnection', IDBConnection::class); - $this->registerService('HTTPHelper', function (Server $c) { - $config = $c->getConfig(); - return new HTTPHelper( - $config, - $c->getHTTPClientService() - ); - }); $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { $user = \OC_User::getUser(); @@ -1583,16 +1576,6 @@ class Server extends ServerContainer implements IServerContainer { } /** - * Returns an instance of the HTTP helper class - * - * @deprecated Use getHTTPClientService() - * @return \OC\HTTPHelper - */ - public function getHTTPHelper() { - return $this->query('HTTPHelper'); - } - - /** * Get the certificate manager for the user * * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index e6056679c1c..4514cdbae1b 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -1991,7 +1991,22 @@ class Share extends Constants { while ($result['success'] === false && $try < 2) { $federationEndpoints = $discoveryService->discover($protocol . $remoteDomain, 'FEDERATED_SHARING'); $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; - $result = \OC::$server->getHTTPHelper()->post($protocol . $remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, $fields); + $client = \OC::$server->getHTTPClientService()->newClient(); + + try { + $response = $client->post( + $protocol . $remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, + [ + 'body' => $fields, + 'connect_timeout' => 10, + ] + ); + + $result = ['success' => true, 'result' => $response->getBody()]; + } catch (\Exception $e) { + $result = ['success' => false, 'result' => $e->getMessage()]; + } + $try++; $protocol = 'http://'; } diff --git a/lib/public/IServerContainer.php b/lib/public/IServerContainer.php index a80fc262eef..19c9578ee23 100644 --- a/lib/public/IServerContainer.php +++ b/lib/public/IServerContainer.php @@ -348,14 +348,6 @@ interface IServerContainer extends IContainer { public function createEventSource(); /** - * Returns an instance of the HTTP helper class - * @return \OC\HTTPHelper - * @deprecated 8.1.0 Use \OCP\Http\Client\IClientService - * @since 8.0.0 - */ - public function getHTTPHelper(); - - /** * Returns an instance of the HTTP client service * * @return \OCP\Http\Client\IClientService |