Merge pull request #20960 from owncloud/drop-OC_Util-getUrlContent
Remove OC_Util::getUrlContent and replace by proper usage of public i…
This commit is contained in:
commit
764b2932ff
|
@ -36,6 +36,12 @@ class AppHelper implements \OCP\IHelper {
|
||||||
* @deprecated 8.1.0 Use \OCP\IServerContainer::getHTTPClientService
|
* @deprecated 8.1.0 Use \OCP\IServerContainer::getHTTPClientService
|
||||||
*/
|
*/
|
||||||
public function getUrlContent($url) {
|
public function getUrlContent($url) {
|
||||||
return \OC_Util::getUrlContent($url);
|
try {
|
||||||
|
$client = \OC::$server->getHTTPClientService()->newClient();
|
||||||
|
$response = $client->get($url);
|
||||||
|
return $response->getBody();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1237,7 +1237,11 @@ class OC_Util {
|
||||||
|
|
||||||
// accessing the file via http
|
// accessing the file via http
|
||||||
$url = OC_Helper::makeURLAbsolute(OC::$WEBROOT . '/data' . $fileName);
|
$url = OC_Helper::makeURLAbsolute(OC::$WEBROOT . '/data' . $fileName);
|
||||||
$content = self::getUrlContent($url);
|
try {
|
||||||
|
$content = \OC::$server->getHTTPClientService()->newClient()->get($url)->getBody();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$content = false;
|
||||||
|
}
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
@unlink($testFile);
|
@unlink($testFile);
|
||||||
|
@ -1312,23 +1316,6 @@ class OC_Util {
|
||||||
return \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate($length, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS);
|
return \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate($length, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 \OC::$server->getHTTPClientService()->newClient()->get($url);
|
|
||||||
*/
|
|
||||||
public static function getUrlContent($url) {
|
|
||||||
try {
|
|
||||||
return \OC::$server->getHTTPHelper()->getUrlContent($url);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the server is running on Windows
|
* Checks whether the server is running on Windows
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue