]> 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 a0d940414e0a7c331be5cd63d08c7f0fa5c5ee4c..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);
                }
 
@@ -201,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);
                }
 
@@ -224,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);
                }
 
@@ -289,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);
                }