1
0
Fork 0

Some more "accept" parameters are added

This commit is contained in:
Michael 2022-03-29 06:24:20 +00:00
commit 1fae0123ec
32 changed files with 111 additions and 60 deletions

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

View 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;

View 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');
}

View 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 => $cookiejar, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_FEED_XML]);
unlink($cookiejar);
if ($curlResult->isTimeout()) {

View 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;

View 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)) {

View 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;

View 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;