Add "Accept" to "head"
This commit is contained in:
parent
908d2594ed
commit
28e3eee91b
|
@ -1204,7 +1204,7 @@ class BBCode
|
||||||
$text = DI::cache()->get($cache_key);
|
$text = DI::cache()->get($cache_key);
|
||||||
|
|
||||||
if (is_null($text)) {
|
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()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
|
$mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1275,7 +1275,7 @@ class BBCode
|
||||||
return $text;
|
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()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
|
$mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Core\System;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Network\HTTPClient\Client\HttpClient;
|
||||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||||
use Friendica\Util\Proxy;
|
use Friendica\Util\Proxy;
|
||||||
|
|
||||||
|
@ -96,11 +97,11 @@ class Link
|
||||||
return $url . $id;
|
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');
|
$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 ($curlResult->isSuccess()) {
|
||||||
if (empty($media['mimetype'])) {
|
if (empty($media['mimetype'])) {
|
||||||
return $curlResult->getHeader('Content-Type')[0] ?? '';
|
return $curlResult->getHeader('Content-Type')[0] ?? '';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user