]> git.mxchange.org Git - friendica.git/blobdiff - src/Network/HTTPRequest.php
Merge pull request #9242 from nupplaphil/bug/9142-message-id
[friendica.git] / src / Network / HTTPRequest.php
index 6fcd610aadbae797fc00d6c535740d29528a0bbb..e4ff041039ed8ba225022000faa6af8f2c159af7 100644 (file)
@@ -137,6 +137,8 @@ class HTTPRequest implements IHTTPRequest
                        @curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']);
                }
 
+               @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
+
                if (!empty($opts['timeout'])) {
                        @curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
                } else {
@@ -190,7 +192,7 @@ class HTTPRequest implements IHTTPRequest
 
                $curlResponse = new CurlResult($url, $s, $curl_info, curl_errno($ch), curl_error($ch));
 
-               if ($curlResponse->isRedirectUrl()) {
+               if (!Network::isRedirectBlocked($url) && $curlResponse->isRedirectUrl()) {
                        $redirects++;
                        $this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
                        @curl_close($ch);
@@ -238,6 +240,8 @@ class HTTPRequest implements IHTTPRequest
                        curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
                }
 
+               @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
+
                if (intval($timeout)) {
                        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
                } else {
@@ -276,7 +280,7 @@ class HTTPRequest implements IHTTPRequest
 
                $curlResponse = new CurlResult($url, $s, $curl_info, curl_errno($ch), curl_error($ch));
 
-               if ($curlResponse->isRedirectUrl()) {
+               if (!Network::isRedirectBlocked($url) && $curlResponse->isRedirectUrl()) {
                        $redirects++;
                        $this->logger->info('Post redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
                        curl_close($ch);
@@ -317,6 +321,11 @@ class HTTPRequest implements IHTTPRequest
                        return $url;
                }
 
+               if (Network::isRedirectBlocked($url)) {
+                       $this->logger->info('Domain should not be redirected.', ['url' => $url]);
+                       return $url;
+               }
+
                $url = Network::stripTrackingQueryParams($url);
 
                if ($depth > 10) {
@@ -331,6 +340,7 @@ class HTTPRequest implements IHTTPRequest
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_HEADER, 1);
                curl_setopt($ch, CURLOPT_NOBODY, 1);
+               curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
                curl_setopt($ch, CURLOPT_TIMEOUT, 10);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent());
@@ -375,6 +385,7 @@ class HTTPRequest implements IHTTPRequest
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_NOBODY, 0);
+               curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
                curl_setopt($ch, CURLOPT_TIMEOUT, 10);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent());