]> git.mxchange.org Git - friendica.git/commitdiff
Move ACCEPT constants to own "enum" class
authorPhilipp <admin@philipp.info>
Sat, 2 Apr 2022 18:26:11 +0000 (20:26 +0200)
committerPhilipp <admin@philipp.info>
Sat, 2 Apr 2022 18:26:11 +0000 (20:26 +0200)
35 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/APContact.php
src/Model/GServer.php
src/Model/Photo.php
src/Model/Post/Link.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/Photo.php
src/Module/Proxy.php
src/Network/HTTPClient/Client/HttpClient.php
src/Network/HTTPClient/Client/HttpClientAccept.php [new file with mode: 0644]
src/Network/Probe.php
src/Protocol/Diaspora.php
src/Protocol/OStatus.php
src/Protocol/Salmon.php
src/Security/ExAuth.php
src/Util/HTTPSignature.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 c1a9df7a53798ad500462e07085b3c9c83e3a939..1ae6047a7dfa0ef45414341eee828037557fb761 100644 (file)
@@ -24,7 +24,7 @@ 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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Protocol\ActivityPub;
 
@@ -59,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'], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+                       $curlResult = DI::httpClient()->get($api . 'statuses/friends.json?screen_name=' . $contact['nick'], [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
 
                        if (!$curlResult->isSuccess()) {
                                DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
index dc086ae19a2347387c3541df6db5bff6e65f9cdb..ba1b7e13b6a9f45cfe957c57816e31f553942f56 100644 (file)
@@ -27,7 +27,7 @@ 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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\Strings;
 
@@ -144,7 +144,7 @@ function redir_magic($a, $cid, $url)
        }
 
        // Test for magic auth on the target system
-       $serverret = DI::httpClient()->head($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
+       $serverret = DI::httpClient()->head($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
        if ($serverret->isSuccess()) {
                $separator = strpos($target_url, '?') ? '&' : '?';
                $target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
index 0be220c517697d74e2134f558603e8907d2df396..1ef72ae1df29ee9c9deb877657114f1f33381316 100644 (file)
@@ -32,7 +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\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\ParseUrl;
@@ -98,7 +98,7 @@ class OEmbed
 
                        if (!in_array($ext, $noexts)) {
                                // try oembed autodiscovery
-                               $html_text = DI::httpClient()->fetch($embedurl, 15, HttpClient::ACCEPT_HTML);
+                               $html_text = DI::httpClient()->fetch($embedurl, 15, HttpClientAccept::HTML);
                                if (!empty($html_text)) {
                                        $dom = new DOMDocument();
                                        if (@$dom->loadHTML($html_text)) {
index e80025bc0565e29d7b5a5dd5241f8ecd15695293..3a7775a6648828b66fbf0f074e7ce7787351fe2a 100644 (file)
@@ -39,7 +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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Object\Image;
 use Friendica\Protocol\Activity;
@@ -502,7 +502,7 @@ class BBCode
                                        continue;
                                }
 
-                               $curlResult = DI::httpClient()->get($mtch[1], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
+                               $curlResult = DI::httpClient()->get($mtch[1], [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE]);
                                if (!$curlResult->isSuccess()) {
                                        continue;
                                }
@@ -1204,7 +1204,7 @@ class BBCode
                $text = DI::cache()->get($cache_key);
 
                if (is_null($text)) {
-                       $curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout'), HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
+                       $curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout'), HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::DEFAULT]);
                        if ($curlResult->isSuccess()) {
                                $mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
                        } else {
@@ -1217,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], 0, HttpClient::ACCEPT_HTML);
+                               $body = DI::httpClient()->fetch($match[1], 0, HttpClientAccept::HTML);
                                if (empty($body)) {
                                        DI::cache()->set($cache_key, $text);
                                        return $text;
@@ -1275,7 +1275,7 @@ class BBCode
                        return $text;
                }
 
-               $curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout'), HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
+               $curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout'), HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::DEFAULT]);
                if ($curlResult->isSuccess()) {
                        $mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
                } else {
@@ -1293,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], 0, HttpClient::ACCEPT_HTML);
+                       $body = DI::httpClient()->fetch($match[1], 0, HttpClientAccept::HTML);
                        if (empty($body)) {
                                DI::cache()->set($cache_key, $text);
                                return $text;
index 3e768b6c750ecda7a244ec9c0eafcb28f22e54ea..edaf03e2d266a7ff1d6527af9cd2194086105580 100644 (file)
@@ -23,7 +23,7 @@ namespace Friendica\Core;
 
 use Friendica\DI;
 use Friendica\Model\Contact;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPException;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Object\Search\ContactResult;
@@ -123,7 +123,7 @@ class Search
                        $searchUrl .= '&page=' . $page;
                }
 
-               $resultJson = DI::httpClient()->fetch($searchUrl, 0, HttpClient::ACCEPT_JSON);
+               $resultJson = DI::httpClient()->fetch($searchUrl, 0, HttpClientAccept::JSON);
 
                $results = json_decode($resultJson, true);
 
@@ -229,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 => HttpClient::ACCEPT_JSON]);
+                       $curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                        if ($curlResult->isSuccess()) {
                                $searchResult = json_decode($curlResult->getBody(), true);
                                if (!empty($searchResult['profiles'])) {
index 3a1dc129fc02ae40a10d2602953d03f3e9aa269a..34cd85edfb42c2c5e1cf3679c7b086de51e8c393 100644 (file)
@@ -25,7 +25,7 @@ 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\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\HTTPSignature;
 
@@ -55,7 +55,7 @@ class ExternalResource implements ICanReadFromStorage
                }
 
                try {
-                       $fetchResult = HTTPSignature::fetchRaw($data->url, $data->uid, [HttpClientOptions::ACCEPT_CONTENT => [HttpClient::ACCEPT_IMAGE]]);
+                       $fetchResult = HTTPSignature::fetchRaw($data->url, $data->uid, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
                } catch (Exception $exception) {
                        throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception);
                }
index 9759876fab5b22a9b7027bba2ba1a1a48e9687b3..1af2c83123666105362ea1f4b5bea391ee013c72 100644 (file)
@@ -28,7 +28,7 @@ use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Database\DBStructure;
 use Friendica\DI;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPException;
 use Friendica\Network\Probe;
 use Friendica\Protocol\ActivityNamespace;
@@ -72,10 +72,10 @@ class APContact
 
                $data = ['addr' => $addr];
                $template = 'https://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr);
-               $webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClient::ACCEPT_JRD_JSON);
+               $webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClientAccept::JRD_JSON);
                if (empty($webfinger['links'])) {
                        $template = 'http://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr);
-                       $webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClient::ACCEPT_JRD_JSON);
+                       $webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClientAccept::JRD_JSON);
                        if (empty($webfinger['links'])) {
                                return [];
                        }
index 731175ea50c18e14f6d51431da8a5fb106a53ef3..bf089d7541a370444082b9351b74f96b7d35f732 100644 (file)
@@ -32,9 +32,9 @@ use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Module\Register;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses;
-use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Protocol\Relay;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
@@ -344,7 +344,7 @@ class GServer
 
                // When a nodeinfo is present, we don't need to dig further
                $xrd_timeout = DI::config()->get('system', 'xrd_timeout');
-               $curlResult = DI::httpClient()->get($url . '/.well-known/nodeinfo', [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/.well-known/nodeinfo', [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if ($curlResult->isTimeout()) {
                        self::setFailure($url);
                        return false;
@@ -352,7 +352,7 @@ class GServer
 
                // On a redirect follow the new host but mark the old one as failure
                if ($curlResult->isSuccess() && !empty($curlResult->getRedirectUrl()) && (parse_url($url, PHP_URL_HOST) != parse_url($curlResult->getRedirectUrl(), PHP_URL_HOST))) {
-                       $curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
+                       $curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
                        if (!empty($curlResult->getRedirectUrl()) && parse_url($url, PHP_URL_HOST) != parse_url($curlResult->getRedirectUrl(), PHP_URL_HOST)) {
                                Logger::info('Found redirect. Mark old entry as failure', ['old' => $url, 'new' => $curlResult->getRedirectUrl()]);
                                self::setFailure($url);
@@ -394,7 +394,7 @@ class GServer
                                        $basedata = ['detection-method' => self::DETECT_MANUAL];
                                }
 
-                               $curlResult = DI::httpClient()->get($baseurl, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
+                               $curlResult = DI::httpClient()->get($baseurl, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
                                if ($curlResult->isSuccess()) {
                                        if (!empty($curlResult->getRedirectUrl()) && (parse_url($baseurl, PHP_URL_HOST) != parse_url($curlResult->getRedirectUrl(), PHP_URL_HOST))) {
                                                Logger::info('Found redirect. Mark old entry as failure', ['old' => $url, 'new' => $curlResult->getRedirectUrl()]);
@@ -418,7 +418,7 @@ class GServer
                                        // When the base path doesn't seem to contain a social network we try the complete path.
                                        // Most detectable system have to be installed in the root directory.
                                        // We checked the base to avoid false positives.
-                                       $curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
+                                       $curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
                                        if ($curlResult->isSuccess()) {
                                                $urldata = self::analyseRootHeader($curlResult, $serverdata);
                                                $urldata = self::analyseRootBody($curlResult, $urldata, $url);
@@ -588,7 +588,7 @@ class GServer
        {
                Logger::info('Discover relay data', ['server' => $server_url]);
 
-               $curlResult = DI::httpClient()->get($server_url . '/.well-known/x-social-relay', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($server_url . '/.well-known/x-social-relay', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess()) {
                        return;
                }
@@ -683,7 +683,7 @@ class GServer
         */
        private static function fetchStatistics(string $url)
        {
-               $curlResult = DI::httpClient()->get($url . '/statistics.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/statistics.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess()) {
                        return [];
                }
@@ -809,7 +809,7 @@ class GServer
         */
        private static function parseNodeinfo1(string $nodeinfo_url)
        {
-               $curlResult = DI::httpClient()->get($nodeinfo_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($nodeinfo_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess()) {
                        return [];
                }
@@ -902,7 +902,7 @@ class GServer
         */
        private static function parseNodeinfo2(string $nodeinfo_url)
        {
-               $curlResult = DI::httpClient()->get($nodeinfo_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($nodeinfo_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess()) {
                        return [];
                }
@@ -997,7 +997,7 @@ class GServer
         */
        private static function fetchSiteinfo(string $url, array $serverdata)
        {
-               $curlResult = DI::httpClient()->get($url . '/siteinfo.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/siteinfo.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess()) {
                        return $serverdata;
                }
@@ -1082,7 +1082,7 @@ class GServer
        private static function validHostMeta(string $url)
        {
                $xrd_timeout = DI::config()->get('system', 'xrd_timeout');
-               $curlResult = DI::httpClient()->get($url . '/.well-known/host-meta', [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_XRD_XML]);
+               $curlResult = DI::httpClient()->get($url . '/.well-known/host-meta', [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::XRD_XML]);
                if (!$curlResult->isSuccess()) {
                        return false;
                }
@@ -1174,7 +1174,7 @@ class GServer
        {
                $serverdata['poco'] = '';
 
-               $curlResult = DI::httpClient()->get($url . '/poco', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/poco', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess()) {
                        return $serverdata;
                }
@@ -1204,7 +1204,7 @@ class GServer
         */
        public static function checkMastodonDirectory(string $url, array $serverdata)
        {
-               $curlResult = DI::httpClient()->get($url . '/api/v1/directory?limit=1', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/api/v1/directory?limit=1', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess()) {
                        return $serverdata;
                }
@@ -1231,7 +1231,7 @@ class GServer
         */
        private static function detectPeertube(string $url, array $serverdata)
        {
-               $curlResult = DI::httpClient()->get($url . '/api/v1/config', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/api/v1/config', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
                        return $serverdata;
                }
@@ -1278,7 +1278,7 @@ class GServer
         */
        private static function detectNextcloud(string $url, array $serverdata)
        {
-               $curlResult = DI::httpClient()->get($url . '/status.php', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/status.php', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
                        return $serverdata;
                }
@@ -1302,7 +1302,7 @@ class GServer
        }
 
        private static function fetchWeeklyUsage(string $url, array $serverdata) {
-               $curlResult = DI::httpClient()->get($url . '/api/v1/instance/activity', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/api/v1/instance/activity', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
                        return $serverdata;
                }
@@ -1370,7 +1370,7 @@ class GServer
         */
        private static function detectMastodonAlikes(string $url, array $serverdata)
        {
-               $curlResult = DI::httpClient()->get($url . '/api/v1/instance', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/api/v1/instance', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
                        return $serverdata;
                }
@@ -1435,7 +1435,7 @@ class GServer
         */
        private static function detectHubzilla(string $url, array $serverdata)
        {
-               $curlResult = DI::httpClient()->get($url . '/api/statusnet/config.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/api/statusnet/config.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
                        return $serverdata;
                }
@@ -1532,7 +1532,7 @@ class GServer
         */
        private static function detectPumpIO(string $url, array $serverdata)
        {
-               $curlResult = DI::httpClient()->get($url . '/.well-known/host-meta.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/.well-known/host-meta.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$curlResult->isSuccess()) {
                        return $serverdata;
                }
@@ -1583,7 +1583,7 @@ class GServer
        private static function detectGNUSocial(string $url, array $serverdata)
        {
                // Test for GNU Social
-               $curlResult = DI::httpClient()->get($url . '/api/gnusocial/version.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/api/gnusocial/version.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
                        ($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
                        $serverdata['platform'] = 'gnusocial';
@@ -1601,7 +1601,7 @@ class GServer
                }
 
                // Test for Statusnet
-               $curlResult = DI::httpClient()->get($url . '/api/statusnet/version.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url . '/api/statusnet/version.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
                        ($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
 
@@ -1639,9 +1639,9 @@ class GServer
        {
                // There is a bug in some versions of Friendica that will return an ActivityStream actor when the content type "application/json" is requested.
                // Because of this me must not use ACCEPT_JSON here.
-               $curlResult = DI::httpClient()->get($url . '/friendica/json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
+               $curlResult = DI::httpClient()->get($url . '/friendica/json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::DEFAULT]);
                if (!$curlResult->isSuccess()) {
-                       $curlResult = DI::httpClient()->get($url . '/friendika/json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
+                       $curlResult = DI::httpClient()->get($url . '/friendika/json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::DEFAULT]);
                        $friendika = true;
                        $platform = 'Friendika';
                } else {
@@ -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), 0, HttpClient::ACCEPT_JSON);
+                       $curlResult = DI::httpClient()->fetch('https://the-federation.info/graphql?query=' . urlencode($query), 0, HttpClientAccept::JSON);
                        if (!empty($curlResult)) {
                                $data = json_decode($curlResult, true);
                                if (!empty($data['data']['nodes'])) {
@@ -1963,7 +1963,7 @@ class GServer
 
                if (!empty($accesstoken)) {
                        $api = 'https://instances.social/api/1.0/instances/list?count=0';
-                       $curlResult = DI::httpClient()->get($api, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $accesstoken]], HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+                       $curlResult = DI::httpClient()->get($api, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $accesstoken]], HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                        if ($curlResult->isSuccess()) {
                                $servers = json_decode($curlResult->getBody(), true);
 
index 74171bd7bdde6f7ee2f9feb2a06838c7ee5f070d..5701eabdb9686df618ecddba2125e747120c5c8a 100644 (file)
@@ -32,7 +32,7 @@ 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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Object\Image;
 use Friendica\Util\DateTimeFormat;
@@ -499,7 +499,7 @@ class Photo
 
                $filename = basename($image_url);
                if (!empty($image_url)) {
-                       $ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
+                       $ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE]);
                        Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
                        $img_str = $ret->getBody();
                        $type = $ret->getContentType();
@@ -915,7 +915,7 @@ class Photo
        {
                $filename = basename($image_url);
                if (!empty($image_url)) {
-                       $ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
+                       $ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE]);
                        Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
                        $img_str = $ret->getBody();
                        $type = $ret->getContentType();
index 6a88e4e03f96e97bbc0183fae6b003d139c343d8..fb7d0edb8ddb88dccad5380e7f56dbc3853a32fc 100644 (file)
@@ -26,7 +26,7 @@ use Friendica\Core\System;
 use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\DI;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\Proxy;
 
@@ -97,7 +97,7 @@ class Link
                return $url . $id;
        }
 
-       private static function fetchMimeType(string $url, string $accept = HttpClient::ACCEPT_DEFAULT)
+       private static function fetchMimeType(string $url, string $accept = HttpClientAccept::DEFAULT)
        {
                $timeout = DI::config()->get('system', 'xrd_timeout');
 
index 660d5f542094ca96b001992cedb6253eb06c75cb..b192bfbe7de21304b9fce77d017aaeec5f3de6fa 100644 (file)
@@ -30,7 +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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\Images;
 use Friendica\Util\Network;
@@ -169,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, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
+                       $curlResult = DI::httpClient()->head($media['url'], [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::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, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
+                               $curlResult = DI::httpClient()->get($media['url'], [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::DEFAULT]);
                        }
 
                        if ($curlResult->isSuccess()) {
index 85af2030013b7ba6d85b0b99f2c6c19e471bbcdd..5fbfc4ba5abe06881ab564dc189905cae582f37b 100644 (file)
@@ -35,7 +35,7 @@ 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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\HTTPException;
 use Friendica\Protocol\Activity;
@@ -751,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()->head($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
+                       $serverret = DI::httpClient()->head($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
                        if ($serverret->isSuccess()) {
                                Logger::info('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path);
                                System::externalRedirect($magic_path);
index 497787d1c8b81abd3d23efcdd892ac43900e27b5..43bb31381cc72bb6dc863e8e263982b34abe9fc1 100644 (file)
@@ -34,7 +34,7 @@ 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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
 use Friendica\Network\HTTPException;
@@ -1152,7 +1152,7 @@ class User
                        $photo_failure = false;
 
                        $filename = basename($photo);
-                       $curlResult = DI::httpClient()->get($photo, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
+                       $curlResult = DI::httpClient()->get($photo, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE]);
                        if ($curlResult->isSuccess()) {
                                Logger::debug('Got picture', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $photo]);
                                $img_str = $curlResult->getBody();
index 4c6eebf33c17e43398d942f409363e1378896640..bebe92e957dd6669165f6966ef6e3a1df6111116 100644 (file)
@@ -32,7 +32,7 @@ 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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\HTTPException\ServiceUnavailableException;
 use Friendica\Util\DateTimeFormat;
@@ -250,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', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_XRD_XML])->isSuccess();
+               return DI::httpClient()->get(DI::baseUrl()->get() . '/.well-known/host-meta', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::XRD_XML])->isSuccess();
        }
 
 }
index cd80453dd35f6dc4e936d2c1123932ab295d21f5..766f2131462b36282b9c452a8fd538b05e37c59f 100644 (file)
@@ -28,7 +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\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Protocol;
 use Friendica\Util\Profiler;
 use Psr\Log\LoggerInterface;
@@ -61,7 +61,7 @@ class Feed extends BaseModule
 
                        $contact = Model\Contact::getByURLForUser($url, local_user(), null);
 
-                       $xml = $this->httpClient->fetch($contact['poll'], 0, HttpClient::ACCEPT_FEED_XML);
+                       $xml = $this->httpClient->fetch($contact['poll'], 0, HttpClientAccept::FEED_XML);
 
                        $import_result = Protocol\Feed::import($xml);
 
index 0af2d2eb00096ec3506f2f96d344bd9751390e79..f2765280b65940c3be960419d1fb989be29b6e81 100644 (file)
@@ -32,7 +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\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPException;
 use Friendica\Network\HTTPException\NotModifiedException;
 use Friendica\Object\Image;
@@ -309,7 +309,7 @@ class Photo extends BaseModule
                                }
                                $mimetext = '';
                                if (!empty($url)) {
-                                       $mime = ParseUrl::getContentType($url, HttpClient::ACCEPT_IMAGE);
+                                       $mime = ParseUrl::getContentType($url, HttpClientAccept::IMAGE);
                                        if (!empty($mime)) {
                                                $mimetext = $mime[0] . '/' . $mime[1];
                                        } else {
index 751b4a29846dbf3fe17348f9aedf305fd49f20ad..3ef3117d691bf465efd4faf1564203bf3f48cdf4 100644 (file)
@@ -25,7 +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\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\HTTPException\NotModifiedException;
 use Friendica\Object\Image;
@@ -83,7 +83,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(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClient::ACCEPT_IMAGE], 'timeout' => 10]);
+               $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
                $img_str = $fetchResult->getBody();
 
                if (!$fetchResult->isSuccess() || empty($img_str)) {
index 8cb2d9cb609771745caafde9fb07862d97cc53ba..1cd53646d1d78ceb620c827aebf6f24530d841c5 100644 (file)
@@ -43,22 +43,6 @@ use Psr\Log\LoggerInterface;
  */
 class HttpClient implements ICanSendHttpRequests
 {
-       /** @var string Default value for "Accept" header */
-       const ACCEPT_DEFAULT   = '*/*';
-       const ACCEPT_ATOM_XML  = 'application/atom+xml,text/xml;q=0.9,*/*;q=0.8';
-       const ACCEPT_FEED_XML  = 'application/atom+xml,application/rss+xml;q=0.9,application/rdf+xml;q=0.8,text/xml;q=0.7,*/*;q=0.6';
-       const ACCEPT_HTML      = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
-       const ACCEPT_IMAGE     = 'image/png,image/jpeg,image/gif,image/*;q=0.9,*/*;q=0.8';
-       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_MAGIC_KEY = 'application/magic-public-key';
-       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';
-
        /** @var LoggerInterface */
        private $logger;
        /** @var Profiler */
@@ -157,7 +141,7 @@ class HttpClient implements ICanSendHttpRequests
                };
 
                if (empty($conf[HttpClientOptions::HEADERS]['Accept'])) {
-                       $conf[HttpClientOptions::HEADERS]['Accept'] = static::ACCEPT_DEFAULT;
+                       $conf[HttpClientOptions::HEADERS]['Accept'] = HttpClientAccept::DEFAULT;
                }
 
                try {
diff --git a/src/Network/HTTPClient/Client/HttpClientAccept.php b/src/Network/HTTPClient/Client/HttpClientAccept.php
new file mode 100644 (file)
index 0000000..7df59fc
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+namespace Friendica\Network\HTTPClient\Client;
+
+class HttpClientAccept
+{
+       /** @var string Default value for "Accept" header */
+       public const DEFAULT = '*/*';
+
+       public const ATOM_XML  = 'application/atom+xml,text/xml;q=0.9,*/*;q=0.8';
+       public const FEED_XML  = 'application/atom+xml,application/rss+xml;q=0.9,application/rdf+xml;q=0.8,text/xml;q=0.7,*/*;q=0.6';
+       public const HTML      = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
+       public const IMAGE     = 'image/png,image/jpeg,image/gif,image/*;q=0.9,*/*;q=0.8';
+       public const JRD_JSON  = 'application/jrd+json,application/json;q=0.9';
+       public const JSON      = 'application/json,*/*;q=0.9';
+       public const JSON_AS   = 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
+       public const MAGIC     = 'application/magic-envelope+xml';
+       public const MAGIC_KEY = 'application/magic-public-key';
+       public const RSS_XML   = 'application/rss+xml,text/xml;q=0.9,*/*;q=0.8';
+       public const TEXT      = 'text/plain,text/*;q=0.9,*/*;q=0.8';
+       public const VIDEO     = 'video/mp4,video/*;q=0.9,*/*;q=0.8';
+       public const XRD_XML   = 'application/xrd+xml,text/xml;q=0.9,*/*;q=0.8';
+}
index 51fb84261b171e19468d93dbe48d7bcc712b800b..8fb9fe85ed2f635690d7352e48eb1a8784cf432e 100644 (file)
@@ -34,7 +34,7 @@ use Friendica\Model\Contact;
 use Friendica\Model\GServer;
 use Friendica\Model\Profile;
 use Friendica\Model\User;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Protocol\ActivityNamespace;
 use Friendica\Protocol\ActivityPub;
@@ -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 => HttpClient::ACCEPT_XRD_XML]);
+               $curlResult = DI::httpClient()->get($ssl_url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::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 => HttpClient::ACCEPT_XRD_XML]);
+                       $curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::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, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
                if (!$curlResult->isSuccess()) {
                        return false;
                }
@@ -531,7 +531,7 @@ class Probe
                                $addr = $nick . '@' . $host;
                        }
 
-                       $webfinger = self::getWebfinger($parts['scheme'] . '://' . $host . self::WEBFINGER, HttpClient::ACCEPT_JRD_JSON, $uri, $addr);
+                       $webfinger = self::getWebfinger($parts['scheme'] . '://' . $host . self::WEBFINGER, HttpClientAccept::JRD_JSON, $uri, $addr);
                        if (empty($webfinger)) {
                                $lrdd = self::hostMeta($host);
                        }
@@ -545,7 +545,7 @@ class Probe
                                                $addr = $nick . '@' . $host;
                                        }
 
-                                       $webfinger = self::getWebfinger($parts['scheme'] . '://' . $host . self::WEBFINGER, HttpClient::ACCEPT_JRD_JSON, $uri, $addr);
+                                       $webfinger = self::getWebfinger($parts['scheme'] . '://' . $host . self::WEBFINGER, HttpClientAccept::JRD_JSON, $uri, $addr);
                                        if (empty($webfinger)) {
                                                $lrdd = self::hostMeta($host);
                                        }
@@ -563,13 +563,13 @@ class Probe
                        $nick = substr($uri, 0, strpos($uri, '@'));
                        $addr = $uri;
 
-                       $webfinger = self::getWebfinger('https://' . $host . self::WEBFINGER, HttpClient::ACCEPT_JRD_JSON, $uri, $addr);
+                       $webfinger = self::getWebfinger('https://' . $host . self::WEBFINGER, HttpClientAccept::JRD_JSON, $uri, $addr);
                        if (self::$istimeout) {
                                return [];
                        }
 
                        if (empty($webfinger)) {
-                               $webfinger = self::getWebfinger('http://' . $host . self::WEBFINGER, HttpClient::ACCEPT_JRD_JSON, $uri, $addr);
+                               $webfinger = self::getWebfinger('http://' . $host . self::WEBFINGER, HttpClientAccept::JRD_JSON, $uri, $addr);
                                if (self::$istimeout) {
                                        return [];
                                }
@@ -834,7 +834,7 @@ class Probe
 
        public static function pollZot($url, $data)
        {
-               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if ($curlResult->isTimeout()) {
                        return $data;
                }
@@ -1000,7 +1000,7 @@ class Probe
         */
        private static function pollNoscrape($noscrape_url, $data)
        {
-               $curlResult = DI::httpClient()->get($noscrape_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($noscrape_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if ($curlResult->isTimeout()) {
                        self::$istimeout = true;
                        return $data;
@@ -1266,7 +1266,7 @@ class Probe
         */
        private static function pollHcard($hcard_url, $data, $dfrn = false)
        {
-               $curlResult = DI::httpClient()->get($hcard_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
+               $curlResult = DI::httpClient()->get($hcard_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
                if ($curlResult->isTimeout()) {
                        self::$istimeout = true;
                        return [];
@@ -1527,7 +1527,7 @@ class Probe
                                                        $pubkey = substr($pubkey, 5);
                                                }
                                        } elseif (Strings::normaliseLink($pubkey) == 'http://') {
-                                               $curlResult = DI::httpClient()->get($pubkey, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_MAGIC_KEY]);
+                                               $curlResult = DI::httpClient()->get($pubkey, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::MAGIC_KEY]);
                                                if ($curlResult->isTimeout()) {
                                                        self::$istimeout = true;
                                                        return $short ? false : [];
@@ -1562,7 +1562,7 @@ class Probe
                }
 
                // Fetch all additional data from the feed
-               $curlResult = DI::httpClient()->get($data["poll"], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_FEED_XML]);
+               $curlResult = DI::httpClient()->get($data["poll"], [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::FEED_XML]);
                if ($curlResult->isTimeout()) {
                        self::$istimeout = true;
                        return [];
@@ -1614,7 +1614,7 @@ class Probe
         */
        private static function pumpioProfileData($profile_link)
        {
-               $curlResult = DI::httpClient()->get($profile_link, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
+               $curlResult = DI::httpClient()->get($profile_link, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
                if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
                        return [];
                }
@@ -1827,7 +1827,7 @@ class Probe
         */
        private static function feed($url, $probe = true)
        {
-               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_FEED_XML]);
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::FEED_XML]);
                if ($curlResult->isTimeout()) {
                        self::$istimeout = true;
                        return [];
@@ -2049,7 +2049,7 @@ class Probe
                        return '';
                }
 
-               $curlResult = DI::httpClient()->get($gserver['noscrape'] . '/' . $data['nick'], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($gserver['noscrape'] . '/' . $data['nick'], [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
 
                if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
                        $noscrape = json_decode($curlResult->getBody(), true);
@@ -2124,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'], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
+               $curlResult = DI::httpClient()->get($data['poll'], [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::ATOM_XML]);
                if (!$curlResult->isSuccess() || !$curlResult->getBody()) {
                        return '';
                }
index 154d65f6f985ba3aedfb282763b7a0642194bf35..4c053a47c996961419c425ab622c41b66a661e9f 100644 (file)
@@ -41,7 +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\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\Probe;
 use Friendica\Util\Crypto;
 use Friendica\Util\DateTimeFormat;
@@ -1060,7 +1060,7 @@ class Diaspora
 
                Logger::info("Fetch post from ".$source_url);
 
-               $envelope = DI::httpClient()->fetch($source_url, 0, HttpClient::ACCEPT_MAGIC);
+               $envelope = DI::httpClient()->fetch($source_url, 0, HttpClientAccept::MAGIC);
                if ($envelope) {
                        Logger::info("Envelope was fetched.");
                        $x = self::verifyMagicEnvelope($envelope);
index 076602f9ab61f1f9b14811bcd389f4a1274f4964..ed63476288cb8705a36eb4f609372218fd6a65e2 100644 (file)
@@ -38,7 +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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\Probe;
 use Friendica\Util\DateTimeFormat;
@@ -732,7 +732,7 @@ class OStatus
 
                self::$conv_list[$conversation] = true;
 
-               $curlResult = DI::httpClient()->get($conversation, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
+               $curlResult = DI::httpClient()->get($conversation, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::ATOM_XML]);
 
                if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
                        return;
@@ -762,7 +762,7 @@ class OStatus
                                        }
                                }
                                if ($file != '') {
-                                       $conversation_atom = DI::httpClient()->get($attribute['href'], [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
+                                       $conversation_atom = DI::httpClient()->get($attribute['href'], [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::ATOM_XML]);
 
                                        if ($conversation_atom->isSuccess()) {
                                                $xml = $conversation_atom->getBody();
@@ -876,7 +876,7 @@ class OStatus
                        return;
                }
 
-               $curlResult = DI::httpClient()->get($self, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
+               $curlResult = DI::httpClient()->get($self, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::ATOM_XML]);
 
                if (!$curlResult->isSuccess()) {
                        return;
@@ -926,7 +926,7 @@ class OStatus
                }
 
                $stored = false;
-               $curlResult = DI::httpClient()->get($related, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
+               $curlResult = DI::httpClient()->get($related, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::ATOM_XML]);
 
                if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
                        return;
@@ -958,7 +958,7 @@ class OStatus
                                        }
                                }
                                if ($atom_file != '') {
-                                       $curlResult = DI::httpClient()->get($atom_file, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
+                                       $curlResult = DI::httpClient()->get($atom_file, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::ATOM_XML]);
 
                                        if ($curlResult->isSuccess()) {
                                                Logger::info('Fetched XML for URI ' . $related_uri);
@@ -970,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', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
+                       $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::ATOM_XML]);
 
                        if ($curlResult->isSuccess()) {
                                Logger::info('GNU Social workaround to fetch XML for URI ' . $related_uri);
@@ -981,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', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_ATOM_XML]);
+                       $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::ATOM_XML]);
 
                        if ($curlResult->isSuccess()) {
                                Logger::info('GNU Social workaround 2 to fetch XML for URI ' . $related_uri);
index 2f12cdf1c80d641d1329da16e1059d6efbb973f1..c24e7f78a357f480ebd74549ccde91a67758f60d 100644 (file)
@@ -23,7 +23,7 @@ namespace Friendica\Protocol;
 
 use Friendica\Core\Logger;
 use Friendica\DI;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\Probe;
 use Friendica\Util\Crypto;
 use Friendica\Util\Strings;
@@ -73,7 +73,7 @@ class Salmon
                                                $ret[$x] = substr($ret[$x], 5);
                                        }
                                } elseif (Strings::normaliseLink($ret[$x]) == 'http://') {
-                                       $ret[$x] = DI::httpClient()->fetch($ret[$x], 0, HttpClient::ACCEPT_MAGIC_KEY);
+                                       $ret[$x] = DI::httpClient()->fetch($ret[$x], 0, HttpClientAccept::MAGIC_KEY);
                                        Logger::debug('Fetched public key', ['url' => $ret[$x]]);
                                }
                        }
index f324b0a960af26cf885040be0fc82f8debceaa82..71eac5ec95f4d13eed0b0ac6730e42bf03a54721 100644 (file)
@@ -57,7 +57,7 @@ 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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\HTTPException;
 use Friendica\Util\PidFile;
@@ -241,7 +241,7 @@ class ExAuth
 
                $url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user;
 
-               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
 
                if (!$curlResult->isSuccess()) {
                        return false;
index 2a48267191d4163d907cf9fe8984e32fc34ccf16..161b0da2d839d293e614e9de252ed58a3742dafa 100644 (file)
@@ -28,7 +28,7 @@ use Friendica\DI;
 use Friendica\Model\APContact;
 use Friendica\Model\Contact;
 use Friendica\Model\User;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 
 /**
@@ -416,7 +416,7 @@ class HTTPSignature
         * @return \Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses CurlResult
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function fetchRaw($request, $uid = 0, $opts = [HttpClientOptions::ACCEPT_CONTENT => [HttpClient::ACCEPT_JSON_AS]])
+       public static function fetchRaw($request, $uid = 0, $opts = [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::JSON_AS]])
        {
                $header = [];
 
index f1e85a37d1d60cf0bf5a79e99db73d93d71249b5..c69b7cb9e02686a0c0743925fb53fcd87d93c55d 100644 (file)
@@ -24,7 +24,7 @@ namespace Friendica\Util;
 use Friendica\Core\Logger;
 use Friendica\DI;
 use Friendica\Model\Photo;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 
 /**
  * Image utilities
@@ -220,7 +220,7 @@ class Images
                }
 
                if (empty($img_str)) {
-                       $img_str = DI::httpClient()->fetch($url, 4, HttpClient::ACCEPT_IMAGE);
+                       $img_str = DI::httpClient()->fetch($url, 4, HttpClientAccept::IMAGE);
                }
 
                if (!$img_str) {
index 06ef3bdd0cd02864596f3ea638d7002a3174f1e1..08d68635a9eef2dc61792337c73eaf7f9263d775 100644 (file)
@@ -29,7 +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\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPException;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 
@@ -59,7 +59,7 @@ class ParseUrl
         * @param string $accept content-type to accept
         * @return array content type
         */
-       public static function getContentType(string $url, string $accept = HttpClient::ACCEPT_DEFAULT)
+       public static function getContentType(string $url, string $accept = HttpClientAccept::DEFAULT)
        {
                $curlResult = DI::httpClient()->head($url, [HttpClientOptions::ACCEPT_CONTENT => $accept]);
 
@@ -222,7 +222,7 @@ class ParseUrl
                        return $siteinfo;
                }
 
-               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::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 d803d9e3ad5afa5f3564115dd0fdcf6f25bdb853..87a9e2a0acfc72ec89c32498131d992531e679aa 100644 (file)
@@ -24,7 +24,7 @@ namespace Friendica\Worker;
 use Friendica\Core\Logger;
 use Friendica\Database\DBA;
 use Friendica\DI;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 
 /**
  * Check the git repository VERSION file and save the version to the DB
@@ -55,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, 0, HttpClient::ACCEPT_TEXT)));
+               $gitversion = DBA::escape(trim(DI::httpClient()->fetch($checked_url, 0, HttpClientAccept::TEXT)));
                Logger::notice("Upstream VERSION is: ".$gitversion);
 
                DI::config()->set('system', 'git_friendica_version', $gitversion);
index d977e522d0062c883ae768c255eba45d40314e94..95d3b3bcc8d6f330b8f83c78723b76d4f6033ee9 100644 (file)
@@ -26,7 +26,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 
 /**
  * Sends updated profile data to the directory
@@ -54,7 +54,7 @@ class Directory
 
                Logger::info('Updating directory: ' . $arr['url']);
                if (strlen($arr['url'])) {
-                       DI::httpClient()->fetch($dir . '?url=' . bin2hex($arr['url']), 0, HttpClient::ACCEPT_HTML);
+                       DI::httpClient()->fetch($dir . '?url=' . bin2hex($arr['url']), 0, HttpClientAccept::HTML);
                }
 
                return;
index f55c494ebda31a147b286eee6811c1ab31c33bd4..0079eb9cd6332a3f01759bf68ec8022ff02b5cb1 100644 (file)
@@ -24,7 +24,7 @@ namespace Friendica\Worker;
 use Friendica\Core\Logger;
 use Friendica\DI;
 use Friendica\Model\Nodeinfo as ModelNodeInfo;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 
 class NodeInfo
 {
@@ -35,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, 0, HttpClient::ACCEPT_HTML);
+               $ret = DI::httpClient()->fetch($url, 0, HttpClientAccept::HTML);
                Logger::debug('Check registering answer', ['answer' => $ret]);
                Logger::info('end');
        }
index 839ab6ce13a85bb21515ab96a41b36599ef7ed5b..79369681ca693ced2eee80f31a92b8e973dad287 100644 (file)
@@ -30,7 +30,7 @@ use Friendica\Model\Contact;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
 use Friendica\Model\User;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Protocol\Activity;
 use Friendica\Protocol\ActivityPub;
@@ -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 => $cookiejar, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::FEED_XML]);
                unlink($cookiejar);
 
                if ($curlResult->isTimeout()) {
index 0ea03a17f3112fec3a853d3850e2ef846ea4822b..87558834ad8cf19a639841aa7980f251e0fec0ca 100644 (file)
@@ -24,7 +24,7 @@ namespace Friendica\Worker;
 use Friendica\Core\Logger;
 use Friendica\DI;
 use Friendica\Model\Contact;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 
 class PullDirectory
 {
@@ -48,7 +48,7 @@ class PullDirectory
 
                Logger::info('Synchronization started.', ['now' => $now, 'directory' => $directory]);
 
-               $result = DI::httpClient()->fetch($directory . '/sync/pull/since/' . $now, 0, HttpClient::ACCEPT_JSON);
+               $result = DI::httpClient()->fetch($directory . '/sync/pull/since/' . $now, 0, HttpClientAccept::JSON);
                if (empty($result)) {
                        Logger::info('Directory server return empty result.', ['directory' => $directory]);
                        return;
index 2344bb1bf6832793595e7f8568f2c4a80feb6705..7a36d2072425fb7f0988b77661e377f7bdb33c90 100644 (file)
@@ -26,7 +26,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\Search;
 use Friendica\DI;
 use Friendica\Model\Contact;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 
 class SearchDirectory
 {
@@ -47,7 +47,7 @@ class SearchDirectory
                        }
                }
 
-               $x = DI::httpClient()->fetch(Search::getGlobalDirectory() . '/lsearch?p=1&n=500&search=' . urlencode($search), 0, HttpClient::ACCEPT_JSON);
+               $x = DI::httpClient()->fetch(Search::getGlobalDirectory() . '/lsearch?p=1&n=500&search=' . urlencode($search), 0, HttpClientAccept::JSON);
                $j = json_decode($x);
 
                if (!empty($j->results)) {
index 248ab1121b3e73780ad003b299f831752e73d023..b3d9c87d2a072fa8e1ac92ae4ebbd489e3990036 100644 (file)
 namespace Friendica\Worker;
 
 use Friendica\Core\Logger;
-use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\GServer;
-use Friendica\Network\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 
 class UpdateServerDirectory
 {
@@ -46,7 +45,7 @@ class UpdateServerDirectory
 
        private static function discoverPoCo(array $gserver)
        {
-               $result = DI::httpClient()->fetch($gserver['poco'] . '?fields=urls', 0, HttpClient::ACCEPT_JSON);
+               $result = DI::httpClient()->fetch($gserver['poco'] . '?fields=urls', 0, HttpClientAccept::JSON);
                if (empty($result)) {
                        Logger::info('Empty result', ['url' => $gserver['url']]);
                        return;
@@ -79,7 +78,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', 0, HttpClient::ACCEPT_JSON);
+               $result = DI::httpClient()->fetch($gserver['url'] . '/api/v1/directory?order=new&local=true&limit=200&offset=0', 0, HttpClientAccept::JSON);
                if (empty($result)) {
                        Logger::info('Empty result', ['url' => $gserver['url']]);
                        return;
index d2a127b82fdfeb77e10e94bbe01589a06b3af0b2..5a889a0ea2d40e762616e086fd9dc95f65e92555 100644 (file)
@@ -25,7 +25,7 @@ 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\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\Strings;
 
@@ -37,7 +37,7 @@ class UpdateServerPeers
         */
        public static function execute(string $url)
        {
-               $ret = DI::httpClient()->get($url . '/api/v1/instance/peers', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
+               $ret = DI::httpClient()->get($url . '/api/v1/instance/peers', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
                if (!$ret->isSuccess() || empty($ret->getBody())) {
                        Logger::info('Server is not reachable or does not offer the "peers" endpoint', ['url' => $url]);
                        return;