From: Michael Date: Tue, 29 Mar 2022 13:34:54 +0000 (+0000) Subject: Add "Accept" to "head" X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=28e3eee91b7a8882afb5ba2fe371dee614ff20a2;p=friendica.git Add "Accept" to "head" --- diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index f30b21351a..e80025bc05 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1204,7 +1204,7 @@ class BBCode $text = DI::cache()->get($cache_key); if (is_null($text)) { - $curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]); + $curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout'), HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]); if ($curlResult->isSuccess()) { $mimetype = $curlResult->getHeader('Content-Type')[0] ?? ''; } else { @@ -1275,7 +1275,7 @@ class BBCode return $text; } - $curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]); + $curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout'), HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]); if ($curlResult->isSuccess()) { $mimetype = $curlResult->getHeader('Content-Type')[0] ?? ''; } else { diff --git a/src/Model/Post/Link.php b/src/Model/Post/Link.php index 78f57425f8..6a88e4e03f 100644 --- a/src/Model/Post/Link.php +++ b/src/Model/Post/Link.php @@ -26,6 +26,7 @@ use Friendica\Core\System; use Friendica\Database\Database; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Network\HTTPClient\Client\HttpClient; use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Util\Proxy; @@ -96,11 +97,11 @@ class Link return $url . $id; } - private static function fetchMimeType(string $url) + private static function fetchMimeType(string $url, string $accept = HttpClient::ACCEPT_DEFAULT) { $timeout = DI::config()->get('system', 'xrd_timeout'); - $curlResult = DI::httpClient()->head($url, [HttpClientOptions::TIMEOUT => $timeout]); + $curlResult = DI::httpClient()->head($url, [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => $accept]); if ($curlResult->isSuccess()) { if (empty($media['mimetype'])) { return $curlResult->getHeader('Content-Type')[0] ?? '';