X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2FHTTPRequest.php;h=79419d38e25fbe581504ce2e963e6e68f1354e7f;hb=5af713b33603c87e72f7b66265af385d22f07afd;hp=87177b1a4081fbb5a6d85a11a87d91463e5bdfb0;hpb=74bc3de4723af3f2bf61705edba090caa102d171;p=friendica.git diff --git a/src/Network/HTTPRequest.php b/src/Network/HTTPRequest.php index 87177b1a40..79419d38e2 100644 --- a/src/Network/HTTPRequest.php +++ b/src/Network/HTTPRequest.php @@ -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 { @@ -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 { @@ -312,6 +316,11 @@ class HTTPRequest implements IHTTPRequest */ public function finalUrl(string $url, int $depth = 1, bool $fetchbody = false) { + if (Network::isUrlBlocked($url)) { + $this->logger->info('Domain is blocked.', ['url' => $url]); + return $url; + } + $url = Network::stripTrackingQueryParams($url); if ($depth > 10) { @@ -326,6 +335,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()); @@ -370,6 +380,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());