X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FNetwork.php;h=e4e9c5af5bb5a75673017425b6cc298057fa74ac;hb=58c8959da0ece9a23966b315310a3962542bc7f4;hp=4d5afa3a362f218b16decfecdcbc09f94a4ed89a;hpb=5e6e1a80250a9b03a0689bbda92a6a66140cc669;p=friendica.git diff --git a/src/Util/Network.php b/src/Util/Network.php index 4d5afa3a36..e4e9c5af5b 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -232,7 +232,7 @@ class Network @curl_close($ch); - $a->getProfiler()->saveTimestamp($stamp1, 'network'); + $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack()); return $curlResponse; } @@ -334,7 +334,7 @@ class Network curl_close($ch); - $a->getProfiler()->saveTimestamp($stamp1, 'network'); + $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack()); Logger::log('post_url: end ' . $url, Logger::DATA); @@ -459,7 +459,6 @@ class Network * @param string $url The url to check the domain from * * @return boolean - * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function isUrlBlocked($url) { @@ -641,7 +640,7 @@ class Network $http_code = $curl_info['http_code']; curl_close($ch); - $a->getProfiler()->saveTimestamp($stamp1, "network"); + $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack()); if ($http_code == 0) { return $url; @@ -683,7 +682,7 @@ class Network $body = curl_exec($ch); curl_close($ch); - $a->getProfiler()->saveTimestamp($stamp1, "network"); + $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack()); if (trim($body) == "") { return $url; @@ -836,4 +835,28 @@ class Network (strlen($query) ? "?".$query : '') . (strlen($fragment) ? "#".$fragment : ''); } + + + /** + * Switch the scheme of an url between http and https + * + * @param string $url URL + * + * @return string switched URL + */ + public static function switchScheme($url) + { + $scheme = parse_url($url, PHP_URL_SCHEME); + if (empty($scheme)) { + return $url; + } + + if ($scheme === 'http') { + $url = str_replace('http://', 'https://', $url); + } elseif ($scheme === 'https') { + $url = str_replace('https://', 'http://', $url); + } + + return $url; + } }