From b2e7ce47b31cbc79dbba2bac91a425f4df63cad8 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 10 Oct 2018 22:08:13 +0200 Subject: [PATCH] Renaming Curl to CurlResult --- src/Network/{Curl.php => CurlResult.php} | 10 +++------- src/Util/Network.php | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 17 deletions(-) rename src/Network/{Curl.php => CurlResult.php} (98%) diff --git a/src/Network/Curl.php b/src/Network/CurlResult.php similarity index 98% rename from src/Network/Curl.php rename to src/Network/CurlResult.php index 7cab25ee87..d100361e22 100644 --- a/src/Network/Curl.php +++ b/src/Network/CurlResult.php @@ -8,7 +8,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException; /** * A content class for Curl call results */ -class Curl +class CurlResult { /** * @var int HTTP return code or 0 if timeout or failure @@ -75,15 +75,11 @@ class Curl * * @param string $url optional URL * - * @return Curl a CURL with error response + * @return CurlResult a CURL with error response */ public static function createErrorCurl($url = '') { - return new Curl( - $url, - '', - [ 'http_code' => 0 ] - ); + return new CurlResult($url,'', [ 'http_code' => 0 ]); } /** diff --git a/src/Util/Network.php b/src/Util/Network.php index 00eaa80fa6..1038fa3f04 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -7,7 +7,7 @@ namespace Friendica\Util; use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Config; -use Friendica\Network\Curl; +use Friendica\Network\CurlResult; use DOMDocument; use DomXPath; @@ -53,7 +53,7 @@ class Network * @param string $accept_content supply Accept: header with 'accept_content' as the value * @param string $cookiejar Path to cookie jar file * - * @return Curl With all relevant information, 'body' contains the actual fetched content. + * @return CurlResult With all relevant information, 'body' contains the actual fetched content. */ public static function fetchUrlFull($url, $binary = false, &$redirects = 0, $timeout = 0, $accept_content = null, $cookiejar = '') { @@ -83,7 +83,7 @@ class Network * 'nobody' => only return the header * 'cookiejar' => path to cookie jar file * - * @return Curl + * @return CurlResult */ public static function curl($url, $binary = false, &$redirects = 0, $opts = []) { @@ -107,13 +107,13 @@ class Network if (self::isUrlBlocked($url)) { logger('domain of ' . $url . ' is blocked', LOGGER_DATA); - return Curl::createErrorCurl($url); + return CurlResult::createErrorCurl($url); } $ch = @curl_init($url); if (($redirects > 8) || (!$ch)) { - return Curl::createErrorCurl($url); + return CurlResult::createErrorCurl($url); } @curl_setopt($ch, CURLOPT_HEADER, true); @@ -208,7 +208,7 @@ class Network $curl_info = @curl_getinfo($ch); } - $curlResponse = new Curl($url, $s, $curl_info, curl_errno($ch), curl_error($ch)); + $curlResponse = new CurlResult($url, $s, $curl_info, curl_errno($ch), curl_error($ch)); if ($curlResponse->isRedirectUrl()) { $redirects++; @@ -233,7 +233,7 @@ class Network * @param integer $redirects Recursion counter for internal use - default = 0 * @param integer $timeout The timeout in seconds, default system config value or 60 seconds * - * @return Curl The content + * @return CurlResult The content */ public static function post($url, $params, $headers = null, &$redirects = 0, $timeout = 0) { @@ -241,14 +241,14 @@ class Network if (self::isUrlBlocked($url)) { logger('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA); - return Curl::createErrorCurl($url); + return CurlResult::createErrorCurl($url); } $a = get_app(); $ch = curl_init($url); if (($redirects > 8) || (!$ch)) { - return Curl::createErrorCurl($url); + return CurlResult::createErrorCurl($url); } logger('post_url: start ' . $url, LOGGER_DATA); @@ -310,7 +310,7 @@ class Network $base = $s; $curl_info = curl_getinfo($ch); - $curlResponse = new Curl($url, $s, $curl_info, curl_errno($ch), curl_error($ch)); + $curlResponse = new CurlResult($url, $s, $curl_info, curl_errno($ch), curl_error($ch)); if ($curlResponse->isRedirectUrl()) { $redirects++;