]> git.mxchange.org Git - friendica.git/blobdiff - src/Network/HTTPRequest.php
Merge branch '2021.03-rc' into copyright-2021
[friendica.git] / src / Network / HTTPRequest.php
index 93ce86c870c829368f0ae90a8b2f58a58acbc6b4..74cf9cd0554d01a62beb0a1486b391bb734f4f69 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU APGL version 3 or any later version
  *
@@ -76,6 +76,7 @@ class HTTPRequest implements IHTTPRequest
 
                if (strlen($url) > 1000) {
                        $this->logger->debug('URL is longer than 1000 characters.', ['url' => $url, 'callstack' => System::callstack(20)]);
+                       $this->profiler->saveTimestamp($stamp1, 'network');
                        return CurlResult::createErrorCurl(substr($url, 0, 200));
                }
 
@@ -94,12 +95,14 @@ class HTTPRequest implements IHTTPRequest
 
                if (Network::isUrlBlocked($url)) {
                        $this->logger->info('Domain is blocked.', ['url' => $url]);
+                       $this->profiler->saveTimestamp($stamp1, 'network');
                        return CurlResult::createErrorCurl($url);
                }
 
                $ch = @curl_init($url);
 
                if (($redirects > 8) || (!$ch)) {
+                       $this->profiler->saveTimestamp($stamp1, 'network');
                        return CurlResult::createErrorCurl($url);
                }
 
@@ -141,7 +144,7 @@ class HTTPRequest implements IHTTPRequest
                curl_setopt($ch, CURLOPT_ENCODING, '');
 
                if (!empty($opts['headers'])) {
-                       $this->logger->warning('Wrong option \'headers\' used.');
+                       $this->logger->notice('Wrong option \'headers\' used.');
                        @curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
                }
 
@@ -184,8 +187,6 @@ class HTTPRequest implements IHTTPRequest
                        curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
                }
 
-               $logger = $this->logger;
-
                $s         = @curl_exec($ch);
                $curl_info = @curl_getinfo($ch);
 
@@ -203,6 +204,7 @@ class HTTPRequest implements IHTTPRequest
                        $redirects++;
                        $this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
                        @curl_close($ch);
+                       $this->profiler->saveTimestamp($stamp1, 'network');
                        return $this->get($curlResponse->getRedirectUrl(), $opts, $redirects);
                }
 
@@ -226,12 +228,14 @@ class HTTPRequest implements IHTTPRequest
 
                if (Network::isUrlBlocked($url)) {
                        $this->logger->info('Domain is blocked.' . ['url' => $url]);
+                       $this->profiler->saveTimestamp($stamp1, 'network');
                        return CurlResult::createErrorCurl($url);
                }
 
                $ch = curl_init($url);
 
                if (($redirects > 8) || (!$ch)) {
+                       $this->profiler->saveTimestamp($stamp1, 'network');
                        return CurlResult::createErrorCurl($url);
                }
 
@@ -291,6 +295,7 @@ class HTTPRequest implements IHTTPRequest
                        $redirects++;
                        $this->logger->info('Post redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
                        curl_close($ch);
+                       $this->profiler->saveTimestamp($stamp1, 'network');
                        return $this->post($curlResponse->getRedirectUrl(), $params, $headers, $redirects, $timeout);
                }