]> git.mxchange.org Git - friendica.git/commitdiff
Some more "accept" parameters are added
authorMichael <heluecht@pirati.ca>
Tue, 29 Mar 2022 06:24:20 +0000 (06:24 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 29 Mar 2022 06:24:20 +0000 (06:24 +0000)
32 files changed:
mod/ostatus_subscribe.php
mod/redir.php
src/Content/OEmbed.php
src/Content/Text/BBCode.php
src/Core/Search.php
src/Core/Storage/Type/ExternalResource.php
src/Model/GServer.php
src/Model/Photo.php
src/Model/Post/Media.php
src/Model/Profile.php
src/Model/User.php
src/Module/Admin/Summary.php
src/Module/Debug/Feed.php
src/Module/Magic.php
src/Module/Photo.php
src/Module/Proxy.php
src/Network/HTTPClient/Client/HttpClient.php
src/Network/Probe.php
src/Protocol/Diaspora.php
src/Protocol/OStatus.php
src/Protocol/Salmon.php
src/Security/ExAuth.php
src/Util/Images.php
src/Util/ParseUrl.php
src/Worker/CheckVersion.php
src/Worker/Directory.php
src/Worker/NodeInfo.php
src/Worker/OnePoll.php
src/Worker/PullDirectory.php
src/Worker/SearchDirectory.php
src/Worker/UpdateServerDirectory.php
src/Worker/UpdateServerPeers.php

index f4d5077c0ad7b4a379ebcdd014288066d9ed2806..c1a9df7a53798ad500462e07085b3c9c83e3a939 100644 (file)
@@ -24,6 +24,8 @@ use Friendica\Core\Protocol;
 use Friendica\DI;
 use Friendica\Model\APContact;
 use Friendica\Model\Contact;
+use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Protocol\ActivityPub;
 
 function ostatus_subscribe_content(App $a)
@@ -57,7 +59,7 @@ function ostatus_subscribe_content(App $a)
                        $api = $contact['baseurl'] . '/api/';
 
                        // Fetching friends
-                       $curlResult = DI::httpClient()->get($api . 'statuses/friends.json?screen_name=' . $contact['nick']);
+                       $curlResult = DI::httpClient()->get($api . 'statuses/friends.json?screen_name=' . $contact['nick'], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
 
                        if (!$curlResult->isSuccess()) {
                                DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
index fe0da9e664a5f796cc5ae7f1ee553d84d0c137c9..5a707d229cd3524b5ff36c47a5fc1246c5d6f054 100644 (file)
@@ -27,6 +27,8 @@ use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Profile;
+use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\Strings;
 
 function redir_init(App $a) {
@@ -142,7 +144,7 @@ function redir_magic($a, $cid, $url)
        }
 
        // Test for magic auth on the target system
-       $serverret = DI::httpClient()->get($basepath . '/magic');
+       $serverret = DI::httpClient()->get($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
        if ($serverret->isSuccess()) {
                $separator = strpos($target_url, '?') ? '&' : '?';
                $target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
index 4e1ae2946f84f442a1b072f4eb07fef68d26f75a..0be220c517697d74e2134f558603e8907d2df396 100644 (file)
@@ -32,6 +32,7 @@ use Friendica\Core\Renderer;
 use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\ParseUrl;
@@ -97,7 +98,7 @@ class OEmbed
 
                        if (!in_array($ext, $noexts)) {
                                // try oembed autodiscovery
-                               $html_text = DI::httpClient()->fetch($embedurl, 15, 'text/*');
+                               $html_text = DI::httpClient()->fetch($embedurl, 15, HttpClient::ACCEPT_HTML);
                                if (!empty($html_text)) {
                                        $dom = new DOMDocument();
                                        if (@$dom->loadHTML($html_text)) {
index 2c17663c1eff360b48e6640c8160e4aebd7b9aca..f30b21351a3afdc4ed6464d90d58ffd8b560c48b 100644 (file)
@@ -39,6 +39,7 @@ use Friendica\Model\Event;
 use Friendica\Model\Photo;
 use Friendica\Model\Post;
 use Friendica\Model\Tag;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Object\Image;
 use Friendica\Protocol\Activity;
@@ -501,11 +502,13 @@ class BBCode
                                        continue;
                                }
 
-                               $curlResult = DI::httpClient()->get($mtch[1]);
+                               $curlResult = DI::httpClient()->get($mtch[1], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
                                if (!$curlResult->isSuccess()) {
                                        continue;
                                }
 
+                               Logger::debug('Got picture', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $mtch[1]]);
+
                                $i = $curlResult->getBody();
                                $type = $curlResult->getContentType();
                                $type = Images::getMimeTypeByData($i, $mtch[1], $type);
@@ -1096,7 +1099,7 @@ class BBCode
                                        $attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
                                }
 
-                               $img_str = '<img src="' . 
+                               $img_str = '<img src="' .
                                self::proxyUrl($match[2], $simplehtml, $uriid) . '"';
                                foreach ($attributes as $key => $value) {
                                        if (!empty($value)) {
@@ -1214,7 +1217,7 @@ class BBCode
                                $text = "[url=" . $match[2] . ']' . $match[2] . "[/url]";
 
                                // if its not a picture then look if its a page that contains a picture link
-                               $body = DI::httpClient()->fetch($match[1]);
+                               $body = DI::httpClient()->fetch($match[1], 0, HttpClient::ACCEPT_HTML);
                                if (empty($body)) {
                                        DI::cache()->set($cache_key, $text);
                                        return $text;
@@ -1290,7 +1293,7 @@ class BBCode
                        }
 
                        // if its not a picture then look if its a page that contains a picture link
-                       $body = DI::httpClient()->fetch($match[1]);
+                       $body = DI::httpClient()->fetch($match[1], 0, HttpClient::ACCEPT_HTML);
                        if (empty($body)) {
                                DI::cache()->set($cache_key, $text);
                                return $text;
@@ -1780,7 +1783,7 @@ class BBCode
 
                                $text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . DI::l10n()->t('Image/photo') . '" />', $text);
                                $text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img src="$1" alt="' . DI::l10n()->t('Image/photo') . '" />', $text);
-       
+
                                $text = self::convertImages($text, $simple_html, $uriid);
 
                                $text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '<br><img src="' .DI::baseUrl() . '/images/lock_icon.gif" alt="' . DI::l10n()->t('Encrypted content') . '" title="' . DI::l10n()->t('Encrypted content') . '" /><br>', $text);
@@ -1894,7 +1897,7 @@ class BBCode
                                } else {
                                        $text = preg_replace("/([#@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $text);
                                }
-                               
+
                                if (!$for_plaintext) {
                                        if (in_array($simple_html, [self::OSTATUS, self::API, self::ACTIVITYPUB])) {
                                                $text = preg_replace_callback("/\[url\](.*?)\[\/url\]/ism", 'self::convertUrlForActivityPubCallback', $text);
index 6c741821e5a138ea2e063f225e584372bc06c5a3..3e768b6c750ecda7a244ec9c0eafcb28f22e54ea 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Core;
 
 use Friendica\DI;
 use Friendica\Model\Contact;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\HTTPException;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Object\Search\ContactResult;
@@ -122,7 +123,7 @@ class Search
                        $searchUrl .= '&page=' . $page;
                }
 
-               $resultJson = DI::httpClient()->fetch($searchUrl, 0, 'application/json');
+               $resultJson = DI::httpClient()->fetch($searchUrl, 0, HttpClient::ACCEPT_JSON);
 
                $results = json_decode($resultJson, true);
 
@@ -228,7 +229,7 @@ class Search
                        $return = Contact::searchByName($search, $mode);
                } else {
                        $p = $page > 1 ? 'p=' . $page : '';
-                       $curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), [HttpClientOptions::ACCEPT_CONTENT => ['application/json']]);
+                       $curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
                        if ($curlResult->isSuccess()) {
                                $searchResult = json_decode($curlResult->getBody(), true);
                                if (!empty($searchResult['profiles'])) {
index 767ec7957d31bf94bbe3e5ddf834c073f8677731..23239965d1463c74dab4837b53b89593a7099ebc 100644 (file)
 namespace Friendica\Core\Storage\Type;
 
 use Exception;
+use Friendica\Core\Logger;
 use Friendica\Core\Storage\Exception\ReferenceStorageException;
 use Friendica\Core\Storage\Capability\ICanReadFromStorage;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Util\HTTPSignature;
 
 /**
@@ -52,11 +54,12 @@ class ExternalResource implements ICanReadFromStorage
                }
 
                try {
-                       $fetchResult = HTTPSignature::fetchRaw($data->url, $data->uid, ['accept_content' => []]);
+                       $fetchResult = HTTPSignature::fetchRaw($data->url, $data->uid, ['accept_content' => [HttpClient::ACCEPT_IMAGE]]);
                } catch (Exception $exception) {
                        throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception);
                }
                if ($fetchResult->isSuccess()) {
+                       Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]);
                        return $fetchResult->getBody();
                } else {
                        throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $fetchResult->getReturnCode(), new Exception($fetchResult->getBody()));
index 3cb4dc5f12c7411f9353ac7393848ce410983b87..731175ea50c18e14f6d51431da8a5fb106a53ef3 100644 (file)
@@ -1946,7 +1946,7 @@ class GServer
                $protocols = ['activitypub', 'diaspora', 'dfrn', 'ostatus'];
                foreach ($protocols as $protocol) {
                        $query = '{nodes(protocol:"' . $protocol . '"){host}}';
-                       $curlResult = DI::httpClient()->fetch('https://the-federation.info/graphql?query=' . urlencode($query));
+                       $curlResult = DI::httpClient()->fetch('https://the-federation.info/graphql?query=' . urlencode($query), 0, HttpClient::ACCEPT_JSON);
                        if (!empty($curlResult)) {
                                $data = json_decode($curlResult, true);
                                if (!empty($data['data']['nodes'])) {
index 8ba01e33655d280ede203d5f774e3c6b51465a42..74171bd7bdde6f7ee2f9feb2a06838c7ee5f070d 100644 (file)
@@ -32,6 +32,8 @@ use Friendica\Core\Storage\Exception\InvalidClassStorageException;
 use Friendica\Core\Storage\Exception\ReferenceStorageException;
 use Friendica\Core\Storage\Exception\StorageException;
 use Friendica\Core\Storage\Type\SystemResource;
+use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Object\Image;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Images;
@@ -497,7 +499,8 @@ class Photo
 
                $filename = basename($image_url);
                if (!empty($image_url)) {
-                       $ret = DI::httpClient()->get($image_url);
+                       $ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
+                       Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
                        $img_str = $ret->getBody();
                        $type = $ret->getContentType();
                } else {
@@ -912,7 +915,8 @@ class Photo
        {
                $filename = basename($image_url);
                if (!empty($image_url)) {
-                       $ret = DI::httpClient()->get($image_url);
+                       $ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
+                       Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
                        $img_str = $ret->getBody();
                        $type = $ret->getContentType();
                } else {
index 254b88115cb1f2d1f2754b95e96901336b9effbe..660d5f542094ca96b001992cedb6253eb06c75cb 100644 (file)
@@ -30,6 +30,7 @@ use Friendica\DI;
 use Friendica\Model\Item;
 use Friendica\Model\Photo;
 use Friendica\Model\Post;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\Images;
 use Friendica\Util\Network;
@@ -168,11 +169,11 @@ class Media
                // Fetch the mimetype or size if missing.
                if (empty($media['mimetype']) || empty($media['size'])) {
                        $timeout = DI::config()->get('system', 'xrd_timeout');
-                       $curlResult = DI::httpClient()->head($media['url'], [HttpClientOptions::TIMEOUT => $timeout]);
+                       $curlResult = DI::httpClient()->head($media['url'], [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
 
                        // Workaround for systems that can't handle a HEAD request
                        if (!$curlResult->isSuccess() && ($curlResult->getReturnCode() == 405)) {
-                               $curlResult = DI::httpClient()->get($media['url'], [HttpClientOptions::TIMEOUT => $timeout]);
+                               $curlResult = DI::httpClient()->get($media['url'], [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
                        }
 
                        if ($curlResult->isSuccess()) {
index d779355202575618dac8bf2b98e593b513c92d00..3a453cc87522c08f245207aab790c393bdeb4396 100644 (file)
@@ -35,6 +35,8 @@ use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\HTTPException;
 use Friendica\Protocol\Activity;
 use Friendica\Protocol\Diaspora;
@@ -749,7 +751,7 @@ class Profile
                        $magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request;
 
                        // We have to check if the remote server does understand /magic without invoking something
-                       $serverret = DI::httpClient()->get($basepath . '/magic');
+                       $serverret = DI::httpClient()->get($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
                        if ($serverret->isSuccess()) {
                                Logger::info('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path);
                                System::externalRedirect($magic_path);
index 93538bce641d684ba3601767fdffcc1a67f7288d..497787d1c8b81abd3d23efcdd892ac43900e27b5 100644 (file)
@@ -34,6 +34,8 @@ use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
 use Friendica\Network\HTTPException;
 use Friendica\Object\Image;
@@ -1150,8 +1152,9 @@ class User
                        $photo_failure = false;
 
                        $filename = basename($photo);
-                       $curlResult = DI::httpClient()->get($photo);
+                       $curlResult = DI::httpClient()->get($photo, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
                        if ($curlResult->isSuccess()) {
+                               Logger::debug('Got picture', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $photo]);
                                $img_str = $curlResult->getBody();
                                $type = $curlResult->getContentType();
                        } else {
index 500732a9f4e9447bc9ce91ed25270fc820e6b392..4c6eebf33c17e43398d942f409363e1378896640 100644 (file)
@@ -32,6 +32,8 @@ use Friendica\DI;
 use Friendica\Core\Config\Factory\Config;
 use Friendica\Model\Register;
 use Friendica\Module\BaseAdmin;
+use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\HTTPException\ServiceUnavailableException;
 use Friendica\Util\DateTimeFormat;
 
@@ -248,7 +250,7 @@ class Summary extends BaseAdmin
        private static function checkSelfHostMeta()
        {
                // Fetch the host-meta to check if this really is a vital server
-               return DI::httpClient()->get(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess();
+               return DI::httpClient()->get(DI::baseUrl()->get() . '/.well-known/host-meta', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_XRD_XML])->isSuccess();
        }
 
 }
index 470b61df2d7c7a4bcc58574ca29fa5ec5190afd8..cd80453dd35f6dc4e936d2c1123932ab295d21f5 100644 (file)
@@ -28,6 +28,7 @@ use Friendica\Core\Renderer;
 use Friendica\Model;
 use Friendica\Module\Response;
 use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Protocol;
 use Friendica\Util\Profiler;
 use Psr\Log\LoggerInterface;
@@ -60,7 +61,7 @@ class Feed extends BaseModule
 
                        $contact = Model\Contact::getByURLForUser($url, local_user(), null);
 
-                       $xml = $this->httpClient->fetch($contact['poll']);
+                       $xml = $this->httpClient->fetch($contact['poll'], 0, HttpClient::ACCEPT_FEED_XML);
 
                        $import_result = Protocol\Feed::import($xml);
 
index f6f3bbc5908120dd06ec1fcf9ed67fb8cc94701e..16b34923765ae9425b4aa20e7ed7d990a7cc53a4 100644 (file)
@@ -29,6 +29,7 @@ use Friendica\Database\Database;
 use Friendica\Model\Contact;
 use Friendica\Model\User;
 use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\HTTPSignature;
 use Friendica\Util\Profiler;
index 3d3110fd8b702fa2458c6c1a2ff61fc775b68637..0af2d2eb00096ec3506f2f96d344bd9751390e79 100644 (file)
@@ -32,6 +32,7 @@ use Friendica\Model\Profile;
 use Friendica\Core\Storage\Type\ExternalResource;
 use Friendica\Core\Storage\Type\SystemResource;
 use Friendica\Model\User;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\HTTPException;
 use Friendica\Network\HTTPException\NotModifiedException;
 use Friendica\Object\Image;
@@ -308,7 +309,7 @@ class Photo extends BaseModule
                                }
                                $mimetext = '';
                                if (!empty($url)) {
-                                       $mime = ParseUrl::getContentType($url);
+                                       $mime = ParseUrl::getContentType($url, HttpClient::ACCEPT_IMAGE);
                                        if (!empty($mime)) {
                                                $mimetext = $mime[0] . '/' . $mime[1];
                                        } else {
@@ -317,6 +318,8 @@ class Photo extends BaseModule
                                        if (!empty($mimetext) && ($mime[0] != 'image') && ($mimetext != 'application/octet-stream')) {
                                                Logger::info('Unexpected Content-Type', ['mime' => $mimetext, 'url' => $url]);
                                                $mimetext = '';
+                                       } if (!empty($mimetext)) {
+                                               Logger::debug('Expected Content-Type', ['mime' => $mimetext, 'url' => $url]);
                                        }
                                }
                                if (empty($mimetext)) {
index 419289c39f6e2927b57871c20abec77e89d39880..dfc8113a4bf3e6ef969520d7be3f199527adf5f3 100644 (file)
@@ -25,6 +25,7 @@ use Friendica\BaseModule;
 use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\DI;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\HTTPException\NotModifiedException;
 use Friendica\Object\Image;
 use Friendica\Util\HTTPSignature;
@@ -81,7 +82,7 @@ class Proxy extends BaseModule
                $request['url'] = str_replace(' ', '+', $request['url']);
 
                // Fetch the content with the local user
-               $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), ['accept_content' => [], 'timeout' => 10]);
+               $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), ['accept_content' => [HttpClient::ACCEPT_IMAGE], 'timeout' => 10]);
                $img_str = $fetchResult->getBody();
 
                if (!$fetchResult->isSuccess() || empty($img_str)) {
@@ -90,6 +91,8 @@ class Proxy extends BaseModule
                        // stop.
                }
 
+               Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => local_user(), 'image' => $request['url']]);
+
                $mime = Images::getMimeTypeByData($img_str);
 
                $image = new Image($img_str, $mime);
index 1f683976243d297021a62e5ab62bc7250e2af430..792cc7965b0463a3ecdab2dbb8685c3277b9de36 100644 (file)
@@ -52,7 +52,9 @@ class HttpClient implements ICanSendHttpRequests
        const ACCEPT_JRD_JSON = 'application/jrd+json,application/json;q=0.9';
        const ACCEPT_JSON     = 'application/json,*/*;q=0.9';
        const ACCEPT_JSON_AS  = 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
+       const ACCEPT_MAGIC    = 'application/magic-envelope+xml';
        const ACCEPT_RSS_XML  = 'application/rss+xml,text/xml;q=0.9,*/*;q=0.8';
+       const ACCEPT_TEXT     = 'text/plain,text/*;q=0.9,*/*;q=0.8';
        const ACCEPT_VIDEO    = 'video/mp4,video/*;q=0.9,*/*;q=0.8';
        const ACCEPT_XRD_XML  = 'application/xrd+xml,text/xml;q=0.9,*/*;q=0.8';
 
index 810885323df40873630a12b839bfa934c82f0a87..ceb684b70c740ca12809e66981f34f0b77d24e12 100644 (file)
@@ -170,7 +170,7 @@ class Probe
                Logger::info('Probing', ['host' => $host, 'ssl_url' => $ssl_url, 'url' => $url, 'callstack' => System::callstack(20)]);
                $xrd = null;
 
-               $curlResult = DI::httpClient()->get($ssl_url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => ['application/xrd+xml']]);
+               $curlResult = DI::httpClient()->get($ssl_url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_XRD_XML]);
                $ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
                if ($curlResult->isSuccess()) {
                        $xml = $curlResult->getBody();
@@ -187,7 +187,7 @@ class Probe
                }
 
                if (!is_object($xrd) && !empty($url)) {
-                       $curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => ['application/xrd+xml']]);
+                       $curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_XRD_XML]);
                        $connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
                        if ($curlResult->isTimeout()) {
                                Logger::info('Probing timeout', ['url' => $url]);
@@ -429,7 +429,7 @@ class Probe
         */
        private static function getHideStatus($url)
        {
-               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000]);
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
                if (!$curlResult->isSuccess()) {
                        return false;
                }
@@ -834,7 +834,8 @@ class Probe
 
        public static function pollZot($url, $data)
        {
-               $curlResult = DI::httpClient()->get($url);
+               // @todo Check if this endpoint might be queried via a POST
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
                if ($curlResult->isTimeout()) {
                        return $data;
                }
@@ -1000,7 +1001,7 @@ class Probe
         */
        private static function pollNoscrape($noscrape_url, $data)
        {
-               $curlResult = DI::httpClient()->get($noscrape_url);
+               $curlResult = DI::httpClient()->get($noscrape_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
                if ($curlResult->isTimeout()) {
                        self::$istimeout = true;
                        return $data;
@@ -1266,7 +1267,7 @@ class Probe
         */
        private static function pollHcard($hcard_url, $data, $dfrn = false)
        {
-               $curlResult = DI::httpClient()->get($hcard_url);
+               $curlResult = DI::httpClient()->get($hcard_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
                if ($curlResult->isTimeout()) {
                        self::$istimeout = true;
                        return [];
@@ -1527,7 +1528,7 @@ class Probe
                                                        $pubkey = substr($pubkey, 5);
                                                }
                                        } elseif (Strings::normaliseLink($pubkey) == 'http://') {
-                                               $curlResult = DI::httpClient()->get($pubkey);
+                                               $curlResult = DI::httpClient()->get($pubkey, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
                                                if ($curlResult->isTimeout()) {
                                                        self::$istimeout = true;
                                                        return $short ? false : [];
@@ -1561,7 +1562,7 @@ class Probe
                }
 
                // Fetch all additional data from the feed
-               $curlResult = DI::httpClient()->get($data["poll"]);
+               $curlResult = DI::httpClient()->get($data["poll"], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_FEED_XML]);
                if ($curlResult->isTimeout()) {
                        self::$istimeout = true;
                        return [];
@@ -1613,7 +1614,7 @@ class Probe
         */
        private static function pumpioProfileData($profile_link)
        {
-               $curlResult = DI::httpClient()->get($profile_link);
+               $curlResult = DI::httpClient()->get($profile_link, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
                if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
                        return [];
                }
@@ -1826,7 +1827,7 @@ class Probe
         */
        private static function feed($url, $probe = true)
        {
-               $curlResult = DI::httpClient()->get($url);
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_FEED_XML]);
                if ($curlResult->isTimeout()) {
                        self::$istimeout = true;
                        return [];
@@ -2048,7 +2049,7 @@ class Probe
                        return '';
                }
 
-               $curlResult = DI::httpClient()->get($gserver['noscrape'] . '/' . $data['nick']);
+               $curlResult = DI::httpClient()->get($gserver['noscrape'] . '/' . $data['nick'], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
 
                if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
                        $noscrape = json_decode($curlResult->getBody(), true);
@@ -2123,7 +2124,7 @@ class Probe
        private static function updateFromFeed(array $data)
        {
                // Search for the newest entry in the feed
-               $curlResult = DI::httpClient()->get($data['poll']);
+               $curlResult = DI::httpClient()->get($data['poll'], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
                if (!$curlResult->isSuccess() || !$curlResult->getBody()) {
                        return '';
                }
index 9f7781d13de19eba1e6730f0a73a3cbde2916918..154d65f6f985ba3aedfb282763b7a0642194bf35 100644 (file)
@@ -41,6 +41,7 @@ use Friendica\Model\Mail;
 use Friendica\Model\Post;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\Probe;
 use Friendica\Util\Crypto;
 use Friendica\Util\DateTimeFormat;
@@ -1059,7 +1060,7 @@ class Diaspora
 
                Logger::info("Fetch post from ".$source_url);
 
-               $envelope = DI::httpClient()->fetch($source_url);
+               $envelope = DI::httpClient()->fetch($source_url, 0, HttpClient::ACCEPT_MAGIC);
                if ($envelope) {
                        Logger::info("Envelope was fetched.");
                        $x = self::verifyMagicEnvelope($envelope);
index a2c9a84473ef33d888dda6f9a895ffbf3f8a0e90..076602f9ab61f1f9b14811bcd389f4a1274f4964 100644 (file)
@@ -38,6 +38,7 @@ use Friendica\Model\ItemURI;
 use Friendica\Model\Post;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\Probe;
 use Friendica\Util\DateTimeFormat;
@@ -731,7 +732,7 @@ class OStatus
 
                self::$conv_list[$conversation] = true;
 
-               $curlResult = DI::httpClient()->get($conversation, [HttpClientOptions::ACCEPT_CONTENT => ['application/atom+xml', 'text/html']]);
+               $curlResult = DI::httpClient()->get($conversation, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
 
                if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
                        return;
@@ -761,7 +762,7 @@ class OStatus
                                        }
                                }
                                if ($file != '') {
-                                       $conversation_atom = DI::httpClient()->get($attribute['href']);
+                                       $conversation_atom = DI::httpClient()->get($attribute['href'], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
 
                                        if ($conversation_atom->isSuccess()) {
                                                $xml = $conversation_atom->getBody();
@@ -875,7 +876,7 @@ class OStatus
                        return;
                }
 
-               $curlResult = DI::httpClient()->get($self);
+               $curlResult = DI::httpClient()->get($self, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
 
                if (!$curlResult->isSuccess()) {
                        return;
@@ -925,7 +926,7 @@ class OStatus
                }
 
                $stored = false;
-               $curlResult = DI::httpClient()->get($related, [HttpClientOptions::ACCEPT_CONTENT => ['application/atom+xml', 'text/html']]);
+               $curlResult = DI::httpClient()->get($related, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
 
                if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
                        return;
@@ -957,7 +958,7 @@ class OStatus
                                        }
                                }
                                if ($atom_file != '') {
-                                       $curlResult = DI::httpClient()->get($atom_file);
+                                       $curlResult = DI::httpClient()->get($atom_file, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
 
                                        if ($curlResult->isSuccess()) {
                                                Logger::info('Fetched XML for URI ' . $related_uri);
@@ -969,7 +970,7 @@ class OStatus
 
                // Workaround for older GNU Social servers
                if (($xml == '') && strstr($related, '/notice/')) {
-                       $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom');
+                       $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
 
                        if ($curlResult->isSuccess()) {
                                Logger::info('GNU Social workaround to fetch XML for URI ' . $related_uri);
@@ -980,7 +981,7 @@ class OStatus
                // Even more worse workaround for GNU Social ;-)
                if ($xml == '') {
                        $related_guess = self::convertHref($related_uri);
-                       $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom');
+                       $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
 
                        if ($curlResult->isSuccess()) {
                                Logger::info('GNU Social workaround 2 to fetch XML for URI ' . $related_uri);
index aecc35e9f9372f34159f7899a320c87c05dc0a55..12d05f9b3d029db2c5334a1e6047c312789b30f4 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Protocol;
 
 use Friendica\Core\Logger;
 use Friendica\DI;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\Probe;
 use Friendica\Util\Crypto;
 use Friendica\Util\Strings;
@@ -72,7 +73,7 @@ class Salmon
                                                $ret[$x] = substr($ret[$x], 5);
                                        }
                                } elseif (Strings::normaliseLink($ret[$x]) == 'http://') {
-                                       $ret[$x] = DI::httpClient()->fetch($ret[$x]);
+                                       $ret[$x] = DI::httpClient()->fetch($ret[$x], 0, HttpClient::ACCEPT_DEFAULT);
                                }
                        }
                }
index a402218f5662890c5bea84cbd9907695254b29d9..f324b0a960af26cf885040be0fc82f8debceaa82 100644 (file)
@@ -57,6 +57,8 @@ use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
 use Friendica\Database\Database;
 use Friendica\DI;
 use Friendica\Model\User;
+use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\HTTPException;
 use Friendica\Util\PidFile;
 
@@ -239,7 +241,7 @@ class ExAuth
 
                $url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user;
 
-               $curlResult = DI::httpClient()->get($url);
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
 
                if (!$curlResult->isSuccess()) {
                        return false;
index d7a58b52aa7faeaf3a275488412c4139405a80e8..f1e85a37d1d60cf0bf5a79e99db73d93d71249b5 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Util;
 use Friendica\Core\Logger;
 use Friendica\DI;
 use Friendica\Model\Photo;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 
 /**
  * Image utilities
@@ -219,7 +220,7 @@ class Images
                }
 
                if (empty($img_str)) {
-                       $img_str = DI::httpClient()->fetch($url, 4);
+                       $img_str = DI::httpClient()->fetch($url, 4, HttpClient::ACCEPT_IMAGE);
                }
 
                if (!$img_str) {
index 24be55cab931ced253b360a51070f93852dcb0d0..06ef3bdd0cd02864596f3ea638d7002a3174f1e1 100644 (file)
@@ -29,6 +29,7 @@ use Friendica\Core\Logger;
 use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\HTTPException;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 
@@ -54,16 +55,17 @@ class ParseUrl
 
        /**
         * Fetch the content type of the given url
-        * @param string $url URL of the page
+        * @param string $url    URL of the page
+        * @param string $accept content-type to accept
         * @return array content type
         */
-       public static function getContentType(string $url)
+       public static function getContentType(string $url, string $accept = HttpClient::ACCEPT_DEFAULT)
        {
-               $curlResult = DI::httpClient()->head($url);
+               $curlResult = DI::httpClient()->head($url, [HttpClientOptions::ACCEPT_CONTENT => $accept]);
 
                // Workaround for systems that can't handle a HEAD request
                if (!$curlResult->isSuccess() && ($curlResult->getReturnCode() == 405)) {
-                       $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000]);
+                       $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::ACCEPT_CONTENT => $accept]);
                }
 
                if (!$curlResult->isSuccess()) {
@@ -220,7 +222,7 @@ class ParseUrl
                        return $siteinfo;
                }
 
-               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000]);
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
                if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
                        Logger::info('Empty body or error when fetching', ['url' => $url, 'success' => $curlResult->isSuccess(), 'code' => $curlResult->getReturnCode()]);
                        return $siteinfo;
index 14ebd87380a072527feb6f06e23782261f927b1b..d803d9e3ad5afa5f3564115dd0fdcf6f25bdb853 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Worker;
 use Friendica\Core\Logger;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 
 /**
  * Check the git repository VERSION file and save the version to the DB
@@ -54,7 +55,7 @@ class CheckVersion
                Logger::info("Checking VERSION from: ".$checked_url);
 
                // fetch the VERSION file
-               $gitversion = DBA::escape(trim(DI::httpClient()->fetch($checked_url)));
+               $gitversion = DBA::escape(trim(DI::httpClient()->fetch($checked_url, 0, HttpClient::ACCEPT_TEXT)));
                Logger::notice("Upstream VERSION is: ".$gitversion);
 
                DI::config()->set('system', 'git_friendica_version', $gitversion);
index d499f778ccfaf4ad4df26eba9b952281b96a4183..db199a856d3b2e0a8824247b3ed67f73d3d212e9 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 
 /**
  * Sends updated profile data to the directory
@@ -53,7 +54,7 @@ class Directory
 
                Logger::info('Updating directory: ' . $arr['url']);
                if (strlen($arr['url'])) {
-                       DI::httpClient()->fetch($dir . '?url=' . bin2hex($arr['url']));
+                       DI::httpClient()->fetch($dir . '?url=' . bin2hex($arr['url']), 0, HttpClient::ACCEPT_DEFAULT);
                }
 
                return;
index 4f18c70609fae3e6fed8ca392bc8a8f4fc99fb9c..f55c494ebda31a147b286eee6811c1ab31c33bd4 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Worker;
 use Friendica\Core\Logger;
 use Friendica\DI;
 use Friendica\Model\Nodeinfo as ModelNodeInfo;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 
 class NodeInfo
 {
@@ -34,7 +35,7 @@ class NodeInfo
                // Now trying to register
                $url = 'http://the-federation.info/register/' . DI::baseUrl()->getHostname();
                Logger::debug('Check registering url', ['url' => $url]);
-               $ret = DI::httpClient()->fetch($url);
+               $ret = DI::httpClient()->fetch($url, 0, HttpClient::ACCEPT_HTML);
                Logger::debug('Check registering answer', ['answer' => $ret]);
                Logger::info('end');
        }
index 40295f0c9d0f06a7b08e6cb973c2e02e0a95c452..839ab6ce13a85bb21515ab96a41b36599ef7ed5b 100644 (file)
@@ -155,7 +155,7 @@ class OnePoll
                }
 
                $cookiejar = tempnam(System::getTempPath(), 'cookiejar-onepoll-');
-               $curlResult = DI::httpClient()->get($contact['poll'], [HttpClientOptions::COOKIEJAR => $cookiejar], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_FEED_XML]);
+               $curlResult = DI::httpClient()->get($contact['poll'], [HttpClientOptions::COOKIEJAR => $cookiejarHttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_FEED_XML]);
                unlink($cookiejar);
 
                if ($curlResult->isTimeout()) {
index 04aab5016a838ea98cd104c45bb51f5542ad636b..0ea03a17f3112fec3a853d3850e2ef846ea4822b 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Worker;
 use Friendica\Core\Logger;
 use Friendica\DI;
 use Friendica\Model\Contact;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 
 class PullDirectory
 {
@@ -47,7 +48,7 @@ class PullDirectory
 
                Logger::info('Synchronization started.', ['now' => $now, 'directory' => $directory]);
 
-               $result = DI::httpClient()->fetch($directory . '/sync/pull/since/' . $now);
+               $result = DI::httpClient()->fetch($directory . '/sync/pull/since/' . $now, 0, HttpClient::ACCEPT_JSON);
                if (empty($result)) {
                        Logger::info('Directory server return empty result.', ['directory' => $directory]);
                        return;
index 9d64268561d3612c63efc6e866e1f98357e1aeab..2344bb1bf6832793595e7f8568f2c4a80feb6705 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\Search;
 use Friendica\DI;
 use Friendica\Model\Contact;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 
 class SearchDirectory
 {
@@ -46,7 +47,7 @@ class SearchDirectory
                        }
                }
 
-               $x = DI::httpClient()->fetch(Search::getGlobalDirectory() . '/lsearch?p=1&n=500&search=' . urlencode($search));
+               $x = DI::httpClient()->fetch(Search::getGlobalDirectory() . '/lsearch?p=1&n=500&search=' . urlencode($search), 0, HttpClient::ACCEPT_JSON);
                $j = json_decode($x);
 
                if (!empty($j->results)) {
index 10cc66cc10da0f3a9e7b3107f5b5af71a3e4e2aa..248ab1121b3e73780ad003b299f831752e73d023 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\GServer;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 
 class UpdateServerDirectory
 {
@@ -45,7 +46,7 @@ class UpdateServerDirectory
 
        private static function discoverPoCo(array $gserver)
        {
-               $result = DI::httpClient()->fetch($gserver['poco'] . '?fields=urls');
+               $result = DI::httpClient()->fetch($gserver['poco'] . '?fields=urls', 0, HttpClient::ACCEPT_JSON);
                if (empty($result)) {
                        Logger::info('Empty result', ['url' => $gserver['url']]);
                        return;
@@ -78,7 +79,7 @@ class UpdateServerDirectory
 
        private static function discoverMastodonDirectory(array $gserver)
        {               
-               $result = DI::httpClient()->fetch($gserver['url'] . '/api/v1/directory?order=new&local=true&limit=200&offset=0');
+               $result = DI::httpClient()->fetch($gserver['url'] . '/api/v1/directory?order=new&local=true&limit=200&offset=0', 0, HttpClient::ACCEPT_JSON);
                if (empty($result)) {
                        Logger::info('Empty result', ['url' => $gserver['url']]);
                        return;
index c14dccc3aaef90f88b880ed220d0e35fb1bab75c..d2a127b82fdfeb77e10e94bbe01589a06b3af0b2 100644 (file)
@@ -25,6 +25,8 @@ use Friendica\Core\Logger;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\GServer;
+use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\Strings;
 
 class UpdateServerPeers
@@ -35,7 +37,7 @@ class UpdateServerPeers
         */
        public static function execute(string $url)
        {
-               $ret = DI::httpClient()->get($url . '/api/v1/instance/peers');
+               $ret = DI::httpClient()->get($url . '/api/v1/instance/peers', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
                if (!$ret->isSuccess() || empty($ret->getBody())) {
                        Logger::info('Server is not reachable or does not offer the "peers" endpoint', ['url' => $url]);
                        return;