continue;
}
- $msearch = json_decode(DI::httpRequest()->post($server . '/msearch', $params)->getBody());
+ $msearch = json_decode(DI::httpClient()->post($server . '/msearch', $params)->getBody());
if (!empty($msearch)) {
$entries = match_get_contacts($msearch, $entries, $limit);
}
$api = $contact['baseurl'] . '/api/';
// Fetching friends
- $curlResult = DI::httpRequest()->get($api . 'statuses/friends.json?screen_name=' . $contact['nick']);
+ $curlResult = DI::httpClient()->get($api . 'statuses/friends.json?screen_name=' . $contact['nick']);
if (!$curlResult->isSuccess()) {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
$hub_callback = rtrim($hub_callback, ' ?&#');
$separator = parse_url($hub_callback, PHP_URL_QUERY) === null ? '?' : '&';
- $fetchResult = DI::httpRequest()->fetchFull($hub_callback . $separator . $params);
+ $fetchResult = DI::httpClient()->fetchFull($hub_callback . $separator . $params);
$body = $fetchResult->getBody();
$ret = $fetchResult->getReturnCode();
}
// Test for magic auth on the target system
- $serverret = DI::httpRequest()->get($basepath . '/magic');
+ $serverret = DI::httpClient()->get($basepath . '/magic');
if ($serverret->isSuccess()) {
$separator = strpos($target_url, '?') ? '&' : '?';
$target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
if (!in_array($ext, $noexts)) {
// try oembed autodiscovery
- $html_text = DI::httpRequest()->fetch($embedurl, 15, 'text/*');
+ $html_text = DI::httpClient()->fetch($embedurl, 15, 'text/*');
if (!empty($html_text)) {
$dom = new DOMDocument();
if (@$dom->loadHTML($html_text)) {
// but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯
$href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'],
['https://www.youtube.com/', 'https://player.vimeo.com/'], $href);
- $result = DI::httpRequest()->fetchFull($href . '&maxwidth=' . $a->getThemeInfoValue('videowidth'));
+ $result = DI::httpClient()->fetchFull($href . '&maxwidth=' . $a->getThemeInfoValue('videowidth'));
if ($result->getReturnCode() === 200) {
$json_string = $result->getBody();
break;
continue;
}
- $curlResult = DI::httpRequest()->get($mtch[1]);
+ $curlResult = DI::httpClient()->get($mtch[1]);
if (!$curlResult->isSuccess()) {
continue;
}
$text = DI::cache()->get($cache_key);
if (is_null($text)) {
- $curlResult = DI::httpRequest()->head($match[1], [HTTPClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]);
+ $curlResult = DI::httpClient()->head($match[1], [HTTPClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]);
if ($curlResult->isSuccess()) {
$mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
} else {
$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::httpRequest()->fetch($match[1]);
+ $body = DI::httpClient()->fetch($match[1]);
if (empty($body)) {
DI::cache()->set($cache_key, $text);
return $text;
return $text;
}
- $curlResult = DI::httpRequest()->head($match[1], [HTTPClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]);
+ $curlResult = DI::httpClient()->head($match[1], [HTTPClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]);
if ($curlResult->isSuccess()) {
$mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
} else {
}
// if its not a picture then look if its a page that contains a picture link
- $body = DI::httpRequest()->fetch($match[1]);
+ $body = DI::httpClient()->fetch($match[1]);
if (empty($body)) {
DI::cache()->set($cache_key, $text);
return $text;
$help = "";
$error_msg = "";
if (function_exists('curl_init')) {
- $fetchResult = DI::httpRequest()->fetchFull($baseurl . "/install/testrewrite");
+ $fetchResult = DI::httpClient()->fetchFull($baseurl . "/install/testrewrite");
$url = Strings::normaliseLink($baseurl . "/install/testrewrite");
if ($fetchResult->getReturnCode() != 204) {
- $fetchResult = DI::httpRequest()->fetchFull($url);
+ $fetchResult = DI::httpClient()->fetchFull($url);
}
if ($fetchResult->getReturnCode() != 204) {
if (preg_match('=https?://(.*)/user/(.*)=ism', $profile_url, $matches)) {
$statusnet_host = $matches[1];
$statusnet_user = $matches[2];
- $UserData = DI::httpRequest()->fetch('http://' . $statusnet_host . '/api/users/show.json?user_id=' . $statusnet_user);
+ $UserData = DI::httpClient()->fetch('http://' . $statusnet_host . '/api/users/show.json?user_id=' . $statusnet_user);
$user = json_decode($UserData);
if ($user) {
$matches[2] = $user->screen_name;
$searchUrl .= '&page=' . $page;
}
- $resultJson = DI::httpRequest()->fetch($searchUrl, 0, 'application/json');
+ $resultJson = DI::httpClient()->fetch($searchUrl, 0, 'application/json');
$results = json_decode($resultJson, true);
$return = Contact::searchByName($search, $mode);
} else {
$p = $page > 1 ? 'p=' . $page : '';
- $curlResult = DI::httpRequest()->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 => ['application/json']]);
if ($curlResult->isSuccess()) {
$searchResult = json_decode($curlResult->getBody(), true);
if (!empty($searchResult['profiles'])) {
/**
* @return Network\IHTTPClient
*/
- public static function httpRequest()
+ public static function httpClient()
{
return self::$dice->create(Network\IHTTPClient::class);
}
// When a nodeinfo is present, we don't need to dig further
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
- $curlResult = DI::httpRequest()->get($url . '/.well-known/nodeinfo', [HTTPClientOptions::TIMEOUT => $xrd_timeout]);
+ $curlResult = DI::httpClient()->get($url . '/.well-known/nodeinfo', [HTTPClientOptions::TIMEOUT => $xrd_timeout]);
if ($curlResult->isTimeout()) {
self::setFailure($url);
return false;
// On a redirect follow the new host but mark the old one as failure
if ($curlResult->isSuccess() && (parse_url($url, PHP_URL_HOST) != parse_url($curlResult->getRedirectUrl(), PHP_URL_HOST))) {
- $curlResult = DI::httpRequest()->get($url, [HTTPClientOptions::TIMEOUT => $xrd_timeout]);
+ $curlResult = DI::httpClient()->get($url, [HTTPClientOptions::TIMEOUT => $xrd_timeout]);
if (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);
$basedata = ['detection-method' => self::DETECT_MANUAL];
}
- $curlResult = DI::httpRequest()->get($baseurl, [HTTPClientOptions::TIMEOUT => $xrd_timeout]);
+ $curlResult = DI::httpClient()->get($baseurl, [HTTPClientOptions::TIMEOUT => $xrd_timeout]);
if ($curlResult->isSuccess()) {
if ((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()]);
// 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::httpRequest()->get($url, [HTTPClientOptions::TIMEOUT => $xrd_timeout]);
+ $curlResult = DI::httpClient()->get($url, [HTTPClientOptions::TIMEOUT => $xrd_timeout]);
if ($curlResult->isSuccess()) {
$urldata = self::analyseRootHeader($curlResult, $serverdata);
$urldata = self::analyseRootBody($curlResult, $urldata, $url);
{
Logger::info('Discover relay data', ['server' => $server_url]);
- $curlResult = DI::httpRequest()->get($server_url . '/.well-known/x-social-relay');
+ $curlResult = DI::httpClient()->get($server_url . '/.well-known/x-social-relay');
if (!$curlResult->isSuccess()) {
return;
}
*/
private static function fetchStatistics(string $url)
{
- $curlResult = DI::httpRequest()->get($url . '/statistics.json');
+ $curlResult = DI::httpClient()->get($url . '/statistics.json');
if (!$curlResult->isSuccess()) {
return [];
}
*/
private static function parseNodeinfo1(string $nodeinfo_url)
{
- $curlResult = DI::httpRequest()->get($nodeinfo_url);
+ $curlResult = DI::httpClient()->get($nodeinfo_url);
if (!$curlResult->isSuccess()) {
return [];
*/
private static function parseNodeinfo2(string $nodeinfo_url)
{
- $curlResult = DI::httpRequest()->get($nodeinfo_url);
+ $curlResult = DI::httpClient()->get($nodeinfo_url);
if (!$curlResult->isSuccess()) {
return [];
}
*/
private static function fetchSiteinfo(string $url, array $serverdata)
{
- $curlResult = DI::httpRequest()->get($url . '/siteinfo.json');
+ $curlResult = DI::httpClient()->get($url . '/siteinfo.json');
if (!$curlResult->isSuccess()) {
return $serverdata;
}
private static function validHostMeta(string $url)
{
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
- $curlResult = DI::httpRequest()->get($url . '/.well-known/host-meta', [HTTPClientOptions::TIMEOUT => $xrd_timeout]);
+ $curlResult = DI::httpClient()->get($url . '/.well-known/host-meta', [HTTPClientOptions::TIMEOUT => $xrd_timeout]);
if (!$curlResult->isSuccess()) {
return false;
}
{
$serverdata['poco'] = '';
- $curlResult = DI::httpRequest()->get($url . '/poco');
+ $curlResult = DI::httpClient()->get($url . '/poco');
if (!$curlResult->isSuccess()) {
return $serverdata;
}
*/
public static function checkMastodonDirectory(string $url, array $serverdata)
{
- $curlResult = DI::httpRequest()->get($url . '/api/v1/directory?limit=1');
+ $curlResult = DI::httpClient()->get($url . '/api/v1/directory?limit=1');
if (!$curlResult->isSuccess()) {
return $serverdata;
}
*/
private static function detectPeertube(string $url, array $serverdata)
{
- $curlResult = DI::httpRequest()->get($url . '/api/v1/config');
+ $curlResult = DI::httpClient()->get($url . '/api/v1/config');
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
return $serverdata;
*/
private static function detectNextcloud(string $url, array $serverdata)
{
- $curlResult = DI::httpRequest()->get($url . '/status.php');
+ $curlResult = DI::httpClient()->get($url . '/status.php');
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
return $serverdata;
*/
private static function detectMastodonAlikes(string $url, array $serverdata)
{
- $curlResult = DI::httpRequest()->get($url . '/api/v1/instance');
+ $curlResult = DI::httpClient()->get($url . '/api/v1/instance');
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
return $serverdata;
*/
private static function detectHubzilla(string $url, array $serverdata)
{
- $curlResult = DI::httpRequest()->get($url . '/api/statusnet/config.json');
+ $curlResult = DI::httpClient()->get($url . '/api/statusnet/config.json');
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
return $serverdata;
}
private static function detectGNUSocial(string $url, array $serverdata)
{
// Test for GNU Social
- $curlResult = DI::httpRequest()->get($url . '/api/gnusocial/version.json');
+ $curlResult = DI::httpClient()->get($url . '/api/gnusocial/version.json');
if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
$serverdata['platform'] = 'gnusocial';
}
// Test for Statusnet
- $curlResult = DI::httpRequest()->get($url . '/api/statusnet/version.json');
+ $curlResult = DI::httpClient()->get($url . '/api/statusnet/version.json');
if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
*/
private static function detectFriendica(string $url, array $serverdata)
{
- $curlResult = DI::httpRequest()->get($url . '/friendica/json');
+ $curlResult = DI::httpClient()->get($url . '/friendica/json');
if (!$curlResult->isSuccess()) {
- $curlResult = DI::httpRequest()->get($url . '/friendika/json');
+ $curlResult = DI::httpClient()->get($url . '/friendika/json');
$friendika = true;
$platform = 'Friendika';
} else {
$protocols = ['activitypub', 'diaspora', 'dfrn', 'ostatus'];
foreach ($protocols as $protocol) {
$query = '{nodes(protocol:"' . $protocol . '"){host}}';
- $curlResult = DI::httpRequest()->fetch('https://the-federation.info/graphql?query=' . urlencode($query));
+ $curlResult = DI::httpClient()->fetch('https://the-federation.info/graphql?query=' . urlencode($query));
if (!empty($curlResult)) {
$data = json_decode($curlResult, true);
if (!empty($data['data']['nodes'])) {
if (!empty($accesstoken)) {
$api = 'https://instances.social/api/1.0/instances/list?count=0';
- $curlResult = DI::httpRequest()->get($api, [HTTPClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $accesstoken]]]);
+ $curlResult = DI::httpClient()->get($api, [HTTPClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $accesstoken]]]);
if ($curlResult->isSuccess()) {
$servers = json_decode($curlResult->getBody(), true);
$filename = basename($image_url);
if (!empty($image_url)) {
- $ret = DI::httpRequest()->get($image_url);
+ $ret = DI::httpClient()->get($image_url);
$img_str = $ret->getBody();
$type = $ret->getContentType();
} else {
{
$timeout = DI::config()->get('system', 'xrd_timeout');
- $curlResult = DI::httpRequest()->head($url, [HTTPClientOptions::TIMEOUT => $timeout]);
+ $curlResult = DI::httpClient()->head($url, [HTTPClientOptions::TIMEOUT => $timeout]);
if ($curlResult->isSuccess()) {
if (empty($media['mimetype'])) {
return $curlResult->getHeader('Content-Type')[0] ?? '';
// Fetch the mimetype or size if missing.
if (empty($media['mimetype']) || empty($media['size'])) {
$timeout = DI::config()->get('system', 'xrd_timeout');
- $curlResult = DI::httpRequest()->head($media['url'], [HTTPClientOptions::TIMEOUT => $timeout]);
+ $curlResult = DI::httpClient()->head($media['url'], [HTTPClientOptions::TIMEOUT => $timeout]);
if ($curlResult->isSuccess()) {
if (empty($media['mimetype'])) {
$media['mimetype'] = $curlResult->getHeader('Content-Type')[0] ?? '';
$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::httpRequest()->get($basepath . '/magic');
+ $serverret = DI::httpClient()->get($basepath . '/magic');
if ($serverret->isSuccess()) {
Logger::log('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, Logger::DEBUG);
System::externalRedirect($magic_path);
$photo_failure = false;
$filename = basename($photo);
- $curlResult = DI::httpRequest()->get($photo);
+ $curlResult = DI::httpClient()->get($photo);
if ($curlResult->isSuccess()) {
$img_str = $curlResult->getBody();
$type = $curlResult->getContentType();
private static function checkSelfHostMeta()
{
// Fetch the host-meta to check if this really is a vital server
- return DI::httpRequest()->get(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess();
+ return DI::httpClient()->get(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess();
}
}
$contact = Model\Contact::getByURLForUser($url, local_user(), null);
- $xml = DI::httpRequest()->fetch($contact['poll']);
+ $xml = DI::httpClient()->fetch($contact['poll']);
$import_result = Protocol\Feed::import($xml);
);
// Try to get an authentication token from the other instance.
- $curlResult = DI::httpRequest()->get($basepath . '/owa', [HTTPClientOptions::HEADERS => $header]);
+ $curlResult = DI::httpClient()->get($basepath . '/owa', [HTTPClientOptions::HEADERS => $header]);
if ($curlResult->isSuccess()) {
$j = json_decode($curlResult->getBody(), true);
Logger::info('Probing', ['host' => $host, 'ssl_url' => $ssl_url, 'url' => $url, 'callstack' => System::callstack(20)]);
$xrd = null;
- $curlResult = DI::httpRequest()->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 => ['application/xrd+xml']]);
$ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
if ($curlResult->isSuccess()) {
$xml = $curlResult->getBody();
}
if (!is_object($xrd) && !empty($url)) {
- $curlResult = DI::httpRequest()->get($url, [HTTPClientOptions::TIMEOUT => $xrd_timeout, HTTPClientOptions::ACCEPT_CONTENT => ['application/xrd+xml']]);
+ $curlResult = DI::httpClient()->get($url, [HTTPClientOptions::TIMEOUT => $xrd_timeout, HTTPClientOptions::ACCEPT_CONTENT => ['application/xrd+xml']]);
$connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
if ($curlResult->isTimeout()) {
Logger::info('Probing timeout', ['url' => $url]);
*/
private static function getHideStatus($url)
{
- $curlResult = DI::httpRequest()->get($url, [HTTPClientOptions::CONTENT_LENGTH => 1000000]);
+ $curlResult = DI::httpClient()->get($url, [HTTPClientOptions::CONTENT_LENGTH => 1000000]);
if (!$curlResult->isSuccess()) {
return false;
}
public static function pollZot($url, $data)
{
- $curlResult = DI::httpRequest()->get($url);
+ $curlResult = DI::httpClient()->get($url);
if ($curlResult->isTimeout()) {
return $data;
}
{
$xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20);
- $curlResult = DI::httpRequest()->get($url, [HTTPClientOptions::TIMEOUT => $xrd_timeout, HTTPClientOptions::ACCEPT_CONTENT => [$type]]);
+ $curlResult = DI::httpClient()->get($url, [HTTPClientOptions::TIMEOUT => $xrd_timeout, HTTPClientOptions::ACCEPT_CONTENT => [$type]]);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
return [];
*/
private static function pollNoscrape($noscrape_url, $data)
{
- $curlResult = DI::httpRequest()->get($noscrape_url);
+ $curlResult = DI::httpClient()->get($noscrape_url);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
return $data;
*/
private static function pollHcard($hcard_url, $data, $dfrn = false)
{
- $curlResult = DI::httpRequest()->get($hcard_url);
+ $curlResult = DI::httpClient()->get($hcard_url);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
return [];
$pubkey = substr($pubkey, 5);
}
} elseif (Strings::normaliseLink($pubkey) == 'http://') {
- $curlResult = DI::httpRequest()->get($pubkey);
+ $curlResult = DI::httpClient()->get($pubkey);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
return $short ? false : [];
}
// Fetch all additional data from the feed
- $curlResult = DI::httpRequest()->get($data["poll"]);
+ $curlResult = DI::httpClient()->get($data["poll"]);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
return [];
*/
private static function pumpioProfileData($profile_link)
{
- $curlResult = DI::httpRequest()->get($profile_link);
+ $curlResult = DI::httpClient()->get($profile_link);
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
return [];
}
*/
private static function feed($url, $probe = true)
{
- $curlResult = DI::httpRequest()->get($url);
+ $curlResult = DI::httpClient()->get($url);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
return [];
return '';
}
- $curlResult = DI::httpRequest()->get($gserver['noscrape'] . '/' . $data['nick']);
+ $curlResult = DI::httpClient()->get($gserver['noscrape'] . '/' . $data['nick']);
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
$noscrape = json_decode($curlResult->getBody(), true);
private static function updateFromFeed(array $data)
{
// Search for the newest entry in the feed
- $curlResult = DI::httpRequest()->get($data['poll']);
+ $curlResult = DI::httpClient()->get($data['poll']);
if (!$curlResult->isSuccess() || !$curlResult->getBody()) {
return '';
}
$content_type = ($public_batch ? "application/magic-envelope+xml" : "application/json");
- $postResult = DI::httpRequest()->post($dest_url, $envelope, ['Content-Type' => $content_type]);
+ $postResult = DI::httpClient()->post($dest_url, $envelope, ['Content-Type' => $content_type]);
$xml = $postResult->getBody();
$curl_stat = $postResult->getReturnCode();
Logger::log("Fetch post from ".$source_url, Logger::DEBUG);
- $envelope = DI::httpRequest()->fetch($source_url);
+ $envelope = DI::httpClient()->fetch($source_url);
if ($envelope) {
Logger::log("Envelope was fetched.", Logger::DEBUG);
$x = self::verifyMagicEnvelope($envelope);
if (!intval(DI::config()->get("system", "diaspora_test"))) {
$content_type = (($public_batch) ? "application/magic-envelope+xml" : "application/json");
- $postResult = DI::httpRequest()->post($dest_url . "/", $envelope, ['Content-Type' => $content_type]);
+ $postResult = DI::httpClient()->post($dest_url . "/", $envelope, ['Content-Type' => $content_type]);
$return_code = $postResult->getReturnCode();
} else {
Logger::log("test_mode");
$dob = '';
if ($profile['dob'] && ($profile['dob'] > '0000-00-00')) {
- list($year, $month, $day) = sscanf($profile['dob'], '%4d-%2d-%2d');
+ [$year, $month, $day] = sscanf($profile['dob'], '%4d-%2d-%2d');
if ($year < 1004) {
$year = 1004;
}
$orig_plink = $item["plink"];
- $item["plink"] = DI::httpRequest()->finalUrl($item["plink"]);
+ $item["plink"] = DI::httpClient()->finalUrl($item["plink"]);
$item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
self::$conv_list[$conversation] = true;
- $curlResult = DI::httpRequest()->get($conversation, [HTTPClientOptions::ACCEPT_CONTENT => ['application/atom+xml', 'text/html']]);
+ $curlResult = DI::httpClient()->get($conversation, [HTTPClientOptions::ACCEPT_CONTENT => ['application/atom+xml', 'text/html']]);
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
return;
}
}
if ($file != '') {
- $conversation_atom = DI::httpRequest()->get($attribute['href']);
+ $conversation_atom = DI::httpClient()->get($attribute['href']);
if ($conversation_atom->isSuccess()) {
$xml = $conversation_atom->getBody();
return;
}
- $curlResult = DI::httpRequest()->get($self);
+ $curlResult = DI::httpClient()->get($self);
if (!$curlResult->isSuccess()) {
return;
}
$stored = false;
- $curlResult = DI::httpRequest()->get($related, [HTTPClientOptions::ACCEPT_CONTENT => ['application/atom+xml', 'text/html']]);
+ $curlResult = DI::httpClient()->get($related, [HTTPClientOptions::ACCEPT_CONTENT => ['application/atom+xml', 'text/html']]);
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
return;
}
}
if ($atom_file != '') {
- $curlResult = DI::httpRequest()->get($atom_file);
+ $curlResult = DI::httpClient()->get($atom_file);
if ($curlResult->isSuccess()) {
Logger::log('Fetched XML for URI ' . $related_uri, Logger::DEBUG);
// Workaround for older GNU Social servers
if (($xml == '') && strstr($related, '/notice/')) {
- $curlResult = DI::httpRequest()->get(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom');
+ $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom');
if ($curlResult->isSuccess()) {
Logger::log('GNU Social workaround to fetch XML for URI ' . $related_uri, Logger::DEBUG);
// Even more worse workaround for GNU Social ;-)
if ($xml == '') {
$related_guess = self::convertHref($related_uri);
- $curlResult = DI::httpRequest()->get(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom');
+ $curlResult = DI::httpClient()->get(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom');
if ($curlResult->isSuccess()) {
Logger::log('GNU Social workaround 2 to fetch XML for URI ' . $related_uri, Logger::DEBUG);
$ret[$x] = substr($ret[$x], 5);
}
} elseif (Strings::normaliseLink($ret[$x]) == 'http://') {
- $ret[$x] = DI::httpRequest()->fetch($ret[$x]);
+ $ret[$x] = DI::httpClient()->fetch($ret[$x]);
}
}
}
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
// slap them
- $postResult = DI::httpRequest()->post($url, $salmon, [
+ $postResult = DI::httpClient()->post($url, $salmon, [
'Content-type' => 'application/magic-envelope+xml',
'Content-length' => strlen($salmon),
]);
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
// slap them
- $postResult = DI::httpRequest()->post($url, $salmon, [
+ $postResult = DI::httpClient()->post($url, $salmon, [
'Content-type' => 'application/magic-envelope+xml',
'Content-length' => strlen($salmon),
]);
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
// slap them
- $postResult = DI::httpRequest()->post($url, $salmon, [
+ $postResult = DI::httpClient()->post($url, $salmon, [
'Content-type' => 'application/magic-envelope+xml',
'Content-length' => strlen($salmon)]);
$return_code = $postResult->getReturnCode();
$url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user;
- $curlResult = DI::httpRequest()->get($url);
+ $curlResult = DI::httpClient()->get($url);
if (!$curlResult->isSuccess()) {
return false;
$headers['Content-Type'] = 'application/activity+json';
- $postResult = DI::httpRequest()->post($target, $content, $headers);
+ $postResult = DI::httpClient()->post($target, $content, $headers);
$return_code = $postResult->getReturnCode();
Logger::log('Transmit to ' . $target . ' returned ' . $return_code, Logger::DEBUG);
$curl_opts[HTTPClientOptions::HEADERS] = $header;
if (!empty($opts['nobody'])) {
- $curlResult = DI::httpRequest()->head($request, $curl_opts);
+ $curlResult = DI::httpClient()->head($request, $curl_opts);
} else {
- $curlResult = DI::httpRequest()->get($request, $curl_opts);
+ $curlResult = DI::httpClient()->get($request, $curl_opts);
}
$return_code = $curlResult->getReturnCode();
}
if (empty($img_str)) {
- $img_str = DI::httpRequest()->fetch($url, 4);
+ $img_str = DI::httpClient()->fetch($url, 4);
}
if (!$img_str) {
*/
public static function getContentType(string $url)
{
- $curlResult = DI::httpRequest()->head($url);
+ $curlResult = DI::httpClient()->head($url);
if (!$curlResult->isSuccess()) {
return [];
}
return $siteinfo;
}
- $curlResult = DI::httpRequest()->get($url, [HTTPClientOptions::CONTENT_LENGTH => 1000000]);
+ $curlResult = DI::httpClient()->get($url, [HTTPClientOptions::CONTENT_LENGTH => 1000000]);
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
return $siteinfo;
}
Logger::log("Checking VERSION from: ".$checked_url, Logger::DEBUG);
// fetch the VERSION file
- $gitversion = DBA::escape(trim(DI::httpRequest()->fetch($checked_url)));
+ $gitversion = DBA::escape(trim(DI::httpClient()->fetch($checked_url)));
Logger::log("Upstream VERSION is: ".$gitversion, Logger::DEBUG);
DI::config()->set('system', 'git_friendica_version', $gitversion);
Logger::log('Updating directory: ' . $arr['url'], Logger::DEBUG);
if (strlen($arr['url'])) {
- DI::httpRequest()->fetch($dir . '?url=' . bin2hex($arr['url']));
+ DI::httpClient()->fetch($dir . '?url=' . bin2hex($arr['url']));
}
return;
// Now trying to register
$url = 'http://the-federation.info/register/' . DI::baseUrl()->getHostname();
Logger::debug('Check registering url', ['url' => $url]);
- $ret = DI::httpRequest()->fetch($url);
+ $ret = DI::httpClient()->fetch($url);
Logger::debug('Check registering answer', ['answer' => $ret]);
Logger::info('end');
}
}
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
- $curlResult = DI::httpRequest()->get($contact['poll'], [HTTPClientOptions::COOKIEJAR => $cookiejar]);
+ $curlResult = DI::httpClient()->get($contact['poll'], [HTTPClientOptions::COOKIEJAR => $cookiejar]);
unlink($cookiejar);
if ($curlResult->isTimeout()) {
DBA::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
}
- $postResult = DI::httpRequest()->post($url, $params);
+ $postResult = DI::httpClient()->post($url, $params);
Logger::info('Hub subscription done', ['result' => $postResult->getReturnCode()]);
Logger::log('POST ' . print_r($headers, true) . "\n" . $params, Logger::DATA);
- $postResult = DI::httpRequest()->post($subscriber['callback_url'], $params, $headers);
+ $postResult = DI::httpClient()->post($subscriber['callback_url'], $params, $headers);
$ret = $postResult->getReturnCode();
if ($ret >= 200 && $ret <= 299) {
Logger::info('Synchronization started.', ['now' => $now, 'directory' => $directory]);
- $result = DI::httpRequest()->fetch($directory . '/sync/pull/since/' . $now);
+ $result = DI::httpClient()->fetch($directory . '/sync/pull/since/' . $now);
if (empty($result)) {
Logger::info('Directory server return empty result.', ['directory' => $directory]);
return;
}
}
- $x = DI::httpRequest()->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));
$j = json_decode($x);
if (!empty($j->results)) {
private static function discoverPoCo(array $gserver)
{
- $result = DI::httpRequest()->fetch($gserver['poco'] . '?fields=urls');
+ $result = DI::httpClient()->fetch($gserver['poco'] . '?fields=urls');
if (empty($result)) {
Logger::info('Empty result', ['url' => $gserver['url']]);
return;
private static function discoverMastodonDirectory(array $gserver)
{
- $result = DI::httpRequest()->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');
if (empty($result)) {
Logger::info('Empty result', ['url' => $gserver['url']]);
return;
*/
public static function execute(string $url)
{
- $ret = DI::httpRequest()->get($url . '/api/v1/instance/peers');
+ $ret = DI::httpClient()->get($url . '/api/v1/instance/peers');
if (!$ret->isSuccess() || empty($ret->getBody())) {
Logger::info('Server is not reachable or does not offer the "peers" endpoint', ['url' => $url]);
return;