@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 {
$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);
@curl_close($ch);
- $this->profiler->saveTimestamp($stamp1, 'network', System::callstack());
+ $this->profiler->saveTimestamp($stamp1, 'network');
return $curlResponse;
}
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}
+ @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
+
if (intval($timeout)) {
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
} else {
$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);
curl_close($ch);
- $this->profiler->saveTimestamp($stamp1, 'network', System::callstack());
+ $this->profiler->saveTimestamp($stamp1, 'network');
// Very old versions of Lighttpd don't like the "Expect" header, so we remove it when needed
if ($curlResponse->getReturnCode() == 417) {
*/
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;
+ }
+
+ if (Network::isRedirectBlocked($url)) {
+ $this->logger->info('Domain should not be redirected.', ['url' => $url]);
+ return $url;
+ }
+
$url = Network::stripTrackingQueryParams($url);
if ($depth > 10) {
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());
$http_code = $curl_info['http_code'];
curl_close($ch);
- $this->profiler->saveTimestamp($stamp1, "network", System::callstack());
+ $this->profiler->saveTimestamp($stamp1, "network");
if ($http_code == 0) {
return $url;
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());
$body = curl_exec($ch);
curl_close($ch);
- $this->profiler->saveTimestamp($stamp1, "network", System::callstack());
+ $this->profiler->saveTimestamp($stamp1, "network");
if (trim($body) == "") {
return $url;