if (!$failed && ($curlResult->getReturnCode() == 410)) {
$data = ['@context' => ActivityPub::CONTEXT, 'id' => $url, 'type' => 'Tombstone'];
- } elseif (!$failed && !HTTPSignature::isValidContentType($curlResult->getContentType())) {
- Logger::debug('Unexpected content type', ['content-type' => $curlResult->getContentType(), 'url' => $url]);
+ } elseif (!$failed && !HTTPSignature::isValidContentType($curlResult->getContentType(), $url)) {
$failed = true;
}
} catch (\Exception $exception) {
}
$curlResult = DI::httpClient()->head($uri, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON_AS]);
- if (HTTPSignature::isValidContentType($curlResult->getContentType())) {
+ if (HTTPSignature::isValidContentType($curlResult->getContentType(), $uri)) {
$fetched_uri = ActivityPub\Processor::fetchMissingActivity($uri, [], '', $completion, $uid);
}
return '';
}
- if (!HTTPSignature::isValidContentType($curlResult->getContentType())) {
- Logger::notice('Unexpected content type', ['content-type' => $curlResult->getContentType(), 'url' => $url]);
+ if (!HTTPSignature::isValidContentType($curlResult->getContentType(), $url)) {
return '';
}
return [];
}
- if (!self::isValidContentType($curlResult->getContentType())) {
- Logger::notice('Unexpected content type', ['content-type' => $curlResult->getContentType(), 'url' => $request]);
+ if (!self::isValidContentType($curlResult->getContentType(), $request)) {
return [];
}
* @param string $contentType
* @return boolean
*/
- public static function isValidContentType(string $contentType): bool
+ public static function isValidContentType(string $contentType, string $url = ''): bool
{
- return in_array(current(explode(';', $contentType)), ['application/activity+json', 'application/ld+json']);
+ if (in_array(current(explode(';', $contentType)), ['application/activity+json', 'application/ld+json'])) {
+ return true;
+ }
+
+ if (current(explode(';', $contentType)) == 'application/json') {
+ Logger::notice('Unexpected content type, possibly from a remote system that is not standard compliant.', ['content-type' => $contentType, 'url' => $url]);
+ }
+ return false;
}
/**