]> git.mxchange.org Git - friendica.git/commitdiff
Add "Accept" to "head"
authorMichael <heluecht@pirati.ca>
Tue, 29 Mar 2022 13:34:54 +0000 (13:34 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 29 Mar 2022 13:34:54 +0000 (13:34 +0000)
src/Content/Text/BBCode.php
src/Model/Post/Link.php

index f30b21351a3afdc4ed6464d90d58ffd8b560c48b..e80025bc0565e29d7b5a5dd5241f8ecd15695293 100644 (file)
@@ -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 {
index 78f57425f890554f1cdd41452460110a43ba6cf2..6a88e4e03f96e97bbc0183fae6b003d139c343d8 100644 (file)
@@ -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] ?? '';