&$report = null) { if (isset($report)) { $report['error'] = 0; $report['message'] = ''; } // Looks like it's an external file, use Guzzle by default if (preg_match('/^(?:http|ftp)s?|s(?:ftp|cp):/', $url)) { /** @var RequestFactory $requestFactory */ $requestFactory = static::makeInstance(RequestFactory::class); if (is_array($requestHeaders)) { // Check is $requestHeaders is an associative array or not if (count(array_filter(array_keys($requestHeaders), 'is_string')) === 0) { trigger_error('Request headers as colon-separated string are deprecated, use an associative array instead.', E_USER_DEPRECATED); // Convert cURL style lines of headers to Guzzle key/value(s) pairs. $requestHeaders = static::splitHeaderLines($requestHeaders); } $configuration = ['headers' => $requestHeaders]; } else { $configuration = []; } $includeHeader = (int)$includeHeader; $method = $includeHeader === 2 ? 'HEAD' : 'GET'; try { if (isset($report)) { $report['lib'] = 'GuzzleHttp'; } $response = $requestFactory->request($url, $method, $configuration); } catch (RequestException $exception) { if (isset($report)) { $report['error'] = $exception->getCode() ?: 1518707554; $report['message'] = $exception->getMessage(); $report['exception'] = $exception;