$this->baseUrl = $baseUrl->get();
}
+ /** {@inheritDoc}
+ *
+ * @throws HTTPException\InternalServerErrorException
+ */
+ public function head(string $url, array $opts = [])
+ {
+ $opts['nobody'] = true;
+
+ return $this->get($url, $opts);
+ }
+
/**
* {@inheritDoc}
*
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));
}
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);
}
curl_setopt($ch, CURLOPT_ENCODING, '');
if (!empty($opts['headers'])) {
+ $this->logger->notice('Wrong option \'headers\' used.');
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
}
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}
- $logger = $this->logger;
-
$s = @curl_exec($ch);
$curl_info = @curl_getinfo($ch);
$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);
}
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);
}
$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);
}