summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2023-03-16 15:28:59 -0100
committerGitHub <noreply@github.com>2023-03-16 15:28:59 -0100
commitc09c8f325872f1193daaebbfb2e9c81e5a812098 (patch)
treec08fca4df9b5df5b999b8526d802c2c695bc69e9 /lib
parentf50922fa161a5e6017098c1194171300439b51ce (diff)
parentf999cfa3051a0eb52397c885cf827f790dee9251 (diff)
Merge pull request #1666 from nextcloud/fix/noid/no-headers-on-webfinger/hostmeta
ignore headers
Diffstat (limited to 'lib')
-rw-r--r--lib/Service/ConfigService.php25
-rw-r--r--lib/Service/CurlService.php2
2 files changed, 16 insertions, 11 deletions
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]);