X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FParseUrl.php;h=24be55cab931ced253b360a51070f93852dcb0d0;hb=093dd70e790def206d6f7d48cfac095c29eb10a5;hp=04afc927ba6cec4229c8167a6bcafe66e4c317d9;hpb=55369613d46eda72d5e120d5cf66703867eb03e3;p=friendica.git diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 04afc927ba..24be55cab9 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -60,13 +60,19 @@ class ParseUrl public static function getContentType(string $url) { $curlResult = DI::httpClient()->head($url); + + // Workaround for systems that can't handle a HEAD request + if (!$curlResult->isSuccess() && ($curlResult->getReturnCode() == 405)) { + $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000]); + } + if (!$curlResult->isSuccess()) { return []; } $contenttype = $curlResult->getHeader('Content-Type')[0] ?? ''; if (empty($contenttype)) { - return []; + return ['application', 'octet-stream']; } return explode('/', current(explode(';', $contenttype)));