Merge pull request #1666 from nextcloud/fix/noid/no-headers-on-webfinger/hostmeta

ignore headers
pull/1667/head
Maxence Lange 2023-03-16 15:28:59 -01:00 zatwierdzone przez GitHub
commit c09c8f3258
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 16 dodań i 11 usunięć

Wyświetl plik

@ -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);

Wyświetl plik

@ -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]);