AVoid throwing an error / store the size of pages

This commit is contained in:
Michael 2024-09-01 18:09:00 +00:00
parent 4dd64b1a5d
commit 7fdf244bae
3 changed files with 8 additions and 4 deletions

View file

@ -61,11 +61,13 @@ class HttpClient implements ICanSendHttpRequests
$host = parse_url($url, PHP_URL_HOST);
if (empty($host)) {
throw new \InvalidArgumentException('Unable to retrieve the host in URL: ' . $url);
$this->logger->notice('Unable to retrieve the host in URL', ['url' => $url]);
$this->profiler->stopRecording();
return CurlResult::createErrorCurl($this->logger, $url);
}
if (!filter_var($host, FILTER_VALIDATE_IP) && !@dns_get_record($host . '.', DNS_A) && !@dns_get_record($host . '.', DNS_AAAA)) {
$this->logger->debug('URL cannot be resolved.', ['url' => $url]);
$this->logger->info('URL cannot be resolved.', ['url' => $url]);
$this->profiler->stopRecording();
return CurlResult::createErrorCurl($this->logger, $url);
}
@ -75,7 +77,7 @@ class HttpClient implements ICanSendHttpRequests
}
if (strlen($url) > 1000) {
$this->logger->debug('URL is longer than 1000 characters.', ['url' => $url]);
$this->logger->info('URL is longer than 1000 characters.', ['url' => $url]);
$this->profiler->stopRecording();
return CurlResult::createErrorCurl($this->logger, substr($url, 0, 200));
}