$method()); } } return $messages; } /** * Check if file exists on given URL. * * @param string $url * @param float|bool $timeoutOverride * * @return bool */ public function fileExists($url, $timeoutOverride = FALSE) { // Timeout past in maybe 0 in which case we should still permit it (0 is infinite). if (!$timeoutOverride && $timeoutOverride !== 0) { $timeoutOverride = (float) Civi::settings()->get('http_timeout'); } $fileExists = FALSE; try { $guzzleClient = new GuzzleHttp\Client(); $guzzleResponse = $guzzleClient->request('GET', $url, array( 'timeout' => $timeoutOverride, )); $fileExists = ($guzzleResponse->getStatusCode() == 200); } catch (Exception $e) { // At this stage we are not checking for variants of not being able to receive it. // However, we might later enhance this to distinguish forbidden from a 500 error. } return $fileExists; } }