]> git.mxchange.org Git - friendica.git/commitdiff
Issue 14126: Workaround for wrong content types
authorMichael <heluecht@pirati.ca>
Sun, 20 Oct 2024 18:38:16 +0000 (18:38 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 20 Oct 2024 18:38:16 +0000 (18:38 +0000)
src/Model/Item.php

index 6ce65dcf6185515a546759bb6689e2a8804f40b1..62b8b78772acc26231d446997ae606ebb827cfab 100644 (file)
@@ -4155,6 +4155,10 @@ class Item
 
                try {
                        $curlResult = DI::httpClient()->head($uri, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON_AS, HttpClientOptions::REQUEST => HttpClientRequest::ACTIVITYPUB]);
+                       if (!HTTPSignature::isValidContentType($curlResult->getContentType(), $uri) && (current(explode(';', $curlResult->getContentType())) == 'application/json')) {
+                               // Issue 14126: Workaround for Mastodon servers that return "application/json" on a "head" request.
+                               $curlResult = HTTPSignature::fetchRaw($uri, $uid);
+                       }
                        if (HTTPSignature::isValidContentType($curlResult->getContentType(), $uri)) {
                                $fetched_uri = ActivityPub\Processor::fetchMissingActivity($uri, [], '', $completion, $uid);
                        }