diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 841d4223..033990b7 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -31,12 +31,12 @@ declare(strict_types=1); namespace OCA\Social\Service; +use OCA\Social\AppInfo\Application; +use OCA\Social\Exceptions\SocialAppConfigException; use OCA\Social\Tools\Model\NCRequest; use OCA\Social\Tools\Model\Request; use OCA\Social\Tools\Traits\TArrayTools; use OCA\Social\Tools\Traits\TPathTools; -use OCA\Social\AppInfo\Application; -use OCA\Social\Exceptions\SocialAppConfigException; use OCP\IConfig; use OCP\IRequest; use OCP\IURLGenerator; @@ -415,16 +415,19 @@ class ConfigService { public function configureRequest(NCRequest $request): void { $request->setVerifyPeer($this->getAppValue(ConfigService::SOCIAL_SELF_SIGNED) !== '1'); - if ($request->getType() === Request::TYPE_GET) { - $request->addHeader( - 'Accept', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' - ); - } + // do not add json headers if required + if (!$this->getBool('ignoreJsonHeaders', $request->getClientOptions())) { + if ($request->getType() === Request::TYPE_GET) { + $request->addHeader( + 'Accept', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' + ); + } - if ($request->getType() === Request::TYPE_POST) { - $request->addHeader( - 'Content-Type', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' - ); + if ($request->getType() === Request::TYPE_POST) { + $request->addHeader( + 'Content-Type', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' + ); + } } $request->setLocalAddressAllowed(true); diff --git a/lib/Service/CurlService.php b/lib/Service/CurlService.php index fc770fd9..f1ef53f3 100644 --- a/lib/Service/CurlService.php +++ b/lib/Service/CurlService.php @@ -126,6 +126,7 @@ class CurlService { $request = new NCRequest($path); $request->addParam('resource', 'acct:' . $account); $request->setHost($host); + $request->setClientOptions(['ignoreJsonHeaders' => true]); $request->setProtocols($protocols); $result = $this->retrieveJson($request); @@ -152,6 +153,7 @@ class CurlService { $request = new NCRequest('/.well-known/host-meta'); $request->setHost($host); $request->setProtocols($protocols); + $request->setClientOptions(['ignoreJsonHeaders' => true]); $this->logger->debug('hostMeta', ['host' => $host, 'protocols' => $protocols]);