mirror of
https://github.com/friendica/friendica
synced 2025-04-27 01:10:14 +00:00
Introduce "accept_header" as specific argument to the http client
This commit is contained in:
parent
73c3b21665
commit
e299fc67c8
35 changed files with 150 additions and 150 deletions
|
@ -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, HttpClientAccept::TEXT)));
|
||||
$gitversion = DBA::escape(trim(DI::httpClient()->fetch($checked_url, HttpClientAccept::TEXT)));
|
||||
Logger::notice("Upstream VERSION is: ".$gitversion);
|
||||
|
||||
DI::config()->set('system', 'git_friendica_version', $gitversion);
|
||||
|
|
|
@ -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, HttpClientAccept::HTML);
|
||||
DI::httpClient()->fetch($dir . '?url=' . bin2hex($arr['url']), HttpClientAccept::HTML);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -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, HttpClientAccept::HTML);
|
||||
$ret = DI::httpClient()->fetch($url, HttpClientAccept::HTML);
|
||||
Logger::debug('Check registering answer', ['answer' => $ret]);
|
||||
Logger::info('end');
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ class OnePoll
|
|||
}
|
||||
|
||||
$cookiejar = tempnam(System::getTempPath(), 'cookiejar-onepoll-');
|
||||
$curlResult = DI::httpClient()->get($contact['poll'], [HttpClientOptions::COOKIEJAR => $cookiejar, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::FEED_XML]);
|
||||
$curlResult = DI::httpClient()->get($contact['poll'], HttpClientAccept::FEED_XML, [HttpClientOptions::COOKIEJAR => $cookiejar]);
|
||||
unlink($cookiejar);
|
||||
|
||||
if ($curlResult->isTimeout()) {
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\Core\Logger;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\PushSubscriber;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Protocol\OStatus;
|
||||
|
||||
class PubSubPublish
|
||||
|
@ -68,7 +69,7 @@ class PubSubPublish
|
|||
|
||||
Logger::debug('POST', ['headers' => $headers, 'params' => $params]);
|
||||
|
||||
$postResult = DI::httpClient()->post($subscriber['callback_url'], $params, $headers);
|
||||
$postResult = DI::httpClient()->post($subscriber['callback_url'], $params, HttpClientAccept::DEFAULT, $headers);
|
||||
$ret = $postResult->getReturnCode();
|
||||
|
||||
if ($ret >= 200 && $ret <= 299) {
|
||||
|
|
|
@ -48,7 +48,7 @@ class PullDirectory
|
|||
|
||||
Logger::info('Synchronization started.', ['now' => $now, 'directory' => $directory]);
|
||||
|
||||
$result = DI::httpClient()->fetch($directory . '/sync/pull/since/' . $now, 0, HttpClientAccept::JSON);
|
||||
$result = DI::httpClient()->fetch($directory . '/sync/pull/since/' . $now, HttpClientAccept::JSON);
|
||||
if (empty($result)) {
|
||||
Logger::info('Directory server return empty result.', ['directory' => $directory]);
|
||||
return;
|
||||
|
|
|
@ -47,7 +47,7 @@ class SearchDirectory
|
|||
}
|
||||
}
|
||||
|
||||
$x = DI::httpClient()->fetch(Search::getGlobalDirectory() . '/lsearch?p=1&n=500&search=' . urlencode($search), 0, HttpClientAccept::JSON);
|
||||
$x = DI::httpClient()->fetch(Search::getGlobalDirectory() . '/lsearch?p=1&n=500&search=' . urlencode($search), HttpClientAccept::JSON);
|
||||
$j = json_decode($x);
|
||||
|
||||
if (!empty($j->results)) {
|
||||
|
|
|
@ -45,7 +45,7 @@ class UpdateServerDirectory
|
|||
|
||||
private static function discoverPoCo(array $gserver)
|
||||
{
|
||||
$result = DI::httpClient()->fetch($gserver['poco'] . '?fields=urls', 0, HttpClientAccept::JSON);
|
||||
$result = DI::httpClient()->fetch($gserver['poco'] . '?fields=urls', HttpClientAccept::JSON);
|
||||
if (empty($result)) {
|
||||
Logger::info('Empty result', ['url' => $gserver['url']]);
|
||||
return;
|
||||
|
@ -78,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, HttpClientAccept::JSON);
|
||||
$result = DI::httpClient()->fetch($gserver['url'] . '/api/v1/directory?order=new&local=true&limit=200&offset=0', HttpClientAccept::JSON);
|
||||
if (empty($result)) {
|
||||
Logger::info('Empty result', ['url' => $gserver['url']]);
|
||||
return;
|
||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\GServer;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
class UpdateServerPeers
|
||||
|
@ -37,7 +36,7 @@ class UpdateServerPeers
|
|||
*/
|
||||
public static function execute(string $url)
|
||||
{
|
||||
$ret = DI::httpClient()->get($url . '/api/v1/instance/peers', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
$ret = DI::httpClient()->get($url . '/api/v1/instance/peers', HttpClientAccept::JSON);
|
||||
if (!$ret->isSuccess() || empty($ret->getBody())) {
|
||||
Logger::info('Server is not reachable or does not offer the "peers" endpoint', ['url' => $url]);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue