Wrap HTTP client call in try catch in Network\Probe

- Address https://github.com/friendica/friendica/issues/13023#issuecomment-1521458475
This commit is contained in:
Hypolite Petovan 2023-05-07 00:26:16 -04:00
parent f673232e53
commit bce7e85e1f

View file

@ -952,9 +952,17 @@ class Probe
*/
public static function webfinger(string $url, string $type): array
{
$xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20);
try {
$curlResult = DI::httpClient()->get(
$url,
$type,
[HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout', 20)]
);
} catch (\Throwable $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'type' => $type, 'class' => get_class($e)]);
return [];
}
$curlResult = DI::httpClient()->get($url, $type, [HttpClientOptions::TIMEOUT => $xrd_timeout]);
if ($curlResult->isTimeout()) {
self::$isTimeout = true;
return [];