Centralized logging for a wrong JSON content-type

This commit is contained in:
Michael 2024-03-08 13:48:21 +00:00
parent 013bba50bc
commit d9bedbb473
4 changed files with 13 additions and 9 deletions

View file

@ -208,8 +208,7 @@ class APContact
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) {

View file

@ -4097,7 +4097,7 @@ class Item
}
$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);
}