Merge pull request #10950 from friendica/issue-10947

Issue 10947: Send correct accept-header for AP
This commit is contained in:
Hypolite Petovan 2021-11-03 15:48:19 -04:00 committed by GitHub
commit 9f411b0c76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 13 deletions

View file

@ -21,6 +21,7 @@
namespace Friendica\Protocol; namespace Friendica\Protocol;
use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Model\APContact; use Friendica\Model\APContact;
use Friendica\Model\User; use Friendica\Model\User;
@ -80,9 +81,15 @@ class ActivityPub
*/ */
public static function isRequest() public static function isRequest()
{ {
return stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') || $isrequest = stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') ||
stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/json') || stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/json') ||
stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json'); stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json');
if ($isrequest) {
Logger::debug('Is AP request', ['accept' => $_SERVER['HTTP_ACCEPT'], 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
}
return $isrequest;
} }
/** /**

View file

@ -68,17 +68,6 @@ class Receiver
const TARGET_ANSWER = 6; const TARGET_ANSWER = 6;
const TARGET_GLOBAL = 7; const TARGET_GLOBAL = 7;
/**
* Checks if the web request is done for the AP protocol
*
* @return bool is it AP?
*/
public static function isRequest()
{
return stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') ||
stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json');
}
/** /**
* Checks incoming message from the inbox * Checks incoming message from the inbox
* *

View file

@ -417,7 +417,7 @@ class HTTPSignature
* @return \Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses CurlResult * @return \Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses CurlResult
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function fetchRaw($request, $uid = 0, $opts = ['accept_content' => ['application/activity+json', 'application/ld+json']]) public static function fetchRaw($request, $uid = 0, $opts = ['accept_content' => ['application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"']])
{ {
$header = []; $header = [];