Make "HTTPRequest::curl" dynamic
This commit is contained in:
parent
9d00e4f1bc
commit
2973ed6448
|
@ -23,7 +23,6 @@ use Friendica\App;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
|
|
||||||
function ostatus_subscribe_content(App $a)
|
function ostatus_subscribe_content(App $a)
|
||||||
{
|
{
|
||||||
|
@ -55,7 +54,7 @@ function ostatus_subscribe_content(App $a)
|
||||||
$api = $contact['baseurl'] . '/api/';
|
$api = $contact['baseurl'] . '/api/';
|
||||||
|
|
||||||
// Fetching friends
|
// Fetching friends
|
||||||
$curlResult = HTTPRequest::curl($api . 'statuses/friends.json?screen_name=' . $contact['nick']);
|
$curlResult = DI::httpRequest()->curl($api . 'statuses/friends.json?screen_name=' . $contact['nick']);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
|
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
|
||||||
|
|
|
@ -28,7 +28,6 @@ use Friendica\Content\PageInfo;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
use Friendica\Util\ParseUrl;
|
use Friendica\Util\ParseUrl;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -85,7 +84,7 @@ function parse_url_content(App $a)
|
||||||
// Check if the URL is an image, video or audio file. If so format
|
// Check if the URL is an image, video or audio file. If so format
|
||||||
// the URL with the corresponding BBCode media tag
|
// the URL with the corresponding BBCode media tag
|
||||||
// Fetch the header of the URL
|
// Fetch the header of the URL
|
||||||
$curlResponse = HTTPRequest::curl($url, false, ['novalidate' => true, 'nobody' => true]);
|
$curlResponse = DI::httpRequest()->curl($url, false, ['novalidate' => true, 'nobody' => true]);
|
||||||
|
|
||||||
if ($curlResponse->isSuccess()) {
|
if ($curlResponse->isSuccess()) {
|
||||||
// Convert the header fields into an array
|
// Convert the header fields into an array
|
||||||
|
|
|
@ -27,7 +27,6 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
function redir_init(App $a) {
|
function redir_init(App $a) {
|
||||||
|
@ -171,7 +170,7 @@ function redir_magic($a, $cid, $url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for magic auth on the target system
|
// Test for magic auth on the target system
|
||||||
$serverret = HTTPRequest::curl($basepath . '/magic');
|
$serverret = DI::httpRequest()->curl($basepath . '/magic');
|
||||||
if ($serverret->isSuccess()) {
|
if ($serverret->isSuccess()) {
|
||||||
$separator = strpos($target_url, '?') ? '&' : '?';
|
$separator = strpos($target_url, '?') ? '&' : '?';
|
||||||
$target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
|
$target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
|
||||||
|
|
|
@ -285,7 +285,7 @@ class Search
|
||||||
$return = GContact::searchByName($search, $mode);
|
$return = GContact::searchByName($search, $mode);
|
||||||
} else {
|
} else {
|
||||||
$p = $page > 1 ? 'p=' . $page : '';
|
$p = $page > 1 ? 'p=' . $page : '';
|
||||||
$curlResult = HTTPRequest::curl(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']);
|
$curlResult = DI::httpRequest()->curl(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']);
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$searchResult = json_decode($curlResult->getBody(), true);
|
$searchResult = json_decode($curlResult->getBody(), true);
|
||||||
if (!empty($searchResult['profiles'])) {
|
if (!empty($searchResult['profiles'])) {
|
||||||
|
|
|
@ -36,7 +36,6 @@ use Friendica\Network\Probe;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Protocol\PortableContact;
|
use Friendica\Protocol\PortableContact;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Network;
|
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -846,7 +845,7 @@ class GContact
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($gserver['noscrape'] . '/' . $data['nick']);
|
$curlResult = DI::httpRequest()->curl($gserver['noscrape'] . '/' . $data['nick']);
|
||||||
|
|
||||||
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
|
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
|
||||||
$noscrape = json_decode($curlResult->getBody(), true);
|
$noscrape = json_decode($curlResult->getBody(), true);
|
||||||
|
@ -928,7 +927,7 @@ class GContact
|
||||||
private static function updateFromFeed(array $data)
|
private static function updateFromFeed(array $data)
|
||||||
{
|
{
|
||||||
// Search for the newest entry in the feed
|
// Search for the newest entry in the feed
|
||||||
$curlResult = HTTPRequest::curl($data['poll']);
|
$curlResult = DI::httpRequest()->curl($data['poll']);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
$fields = ['failed' => true, 'last_failure' => DateTimeFormat::utcNow()];
|
$fields = ['failed' => true, 'last_failure' => DateTimeFormat::utcNow()];
|
||||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
||||||
|
@ -1206,7 +1205,7 @@ class GContact
|
||||||
|
|
||||||
$url = $server . '/main/statistics';
|
$url = $server . '/main/statistics';
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,7 +310,7 @@ class GServer
|
||||||
|
|
||||||
// When a nodeinfo is present, we don't need to dig further
|
// When a nodeinfo is present, we don't need to dig further
|
||||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||||
$curlResult = HTTPRequest::curl($url . '/.well-known/nodeinfo', false, ['timeout' => $xrd_timeout]);
|
$curlResult = DI::httpRequest()->curl($url . '/.well-known/nodeinfo', false, ['timeout' => $xrd_timeout]);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::setFailure($url);
|
self::setFailure($url);
|
||||||
return false;
|
return false;
|
||||||
|
@ -343,7 +343,7 @@ class GServer
|
||||||
$basedata = ['detection-method' => self::DETECT_MANUAL];
|
$basedata = ['detection-method' => self::DETECT_MANUAL];
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($baseurl, false, ['timeout' => $xrd_timeout]);
|
$curlResult = DI::httpRequest()->curl($baseurl, false, ['timeout' => $xrd_timeout]);
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$basedata = self::analyseRootHeader($curlResult, $basedata);
|
$basedata = self::analyseRootHeader($curlResult, $basedata);
|
||||||
$basedata = self::analyseRootBody($curlResult, $basedata, $baseurl);
|
$basedata = self::analyseRootBody($curlResult, $basedata, $baseurl);
|
||||||
|
@ -499,7 +499,7 @@ class GServer
|
||||||
{
|
{
|
||||||
Logger::info('Discover relay data', ['server' => $server_url]);
|
Logger::info('Discover relay data', ['server' => $server_url]);
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($server_url . '/.well-known/x-social-relay');
|
$curlResult = DI::httpRequest()->curl($server_url . '/.well-known/x-social-relay');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -580,7 +580,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function fetchStatistics(string $url)
|
private static function fetchStatistics(string $url)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($url . '/statistics.json');
|
$curlResult = DI::httpRequest()->curl($url . '/statistics.json');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -690,7 +690,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function parseNodeinfo1(string $nodeinfo_url)
|
private static function parseNodeinfo1(string $nodeinfo_url)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($nodeinfo_url);
|
$curlResult = DI::httpRequest()->curl($nodeinfo_url);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return [];
|
return [];
|
||||||
|
@ -767,7 +767,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function parseNodeinfo2(string $nodeinfo_url)
|
private static function parseNodeinfo2(string $nodeinfo_url)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($nodeinfo_url);
|
$curlResult = DI::httpRequest()->curl($nodeinfo_url);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -844,7 +844,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function fetchSiteinfo(string $url, array $serverdata)
|
private static function fetchSiteinfo(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($url . '/siteinfo.json');
|
$curlResult = DI::httpRequest()->curl($url . '/siteinfo.json');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
}
|
}
|
||||||
|
@ -913,7 +913,7 @@ class GServer
|
||||||
private static function validHostMeta(string $url)
|
private static function validHostMeta(string $url)
|
||||||
{
|
{
|
||||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||||
$curlResult = HTTPRequest::curl($url . '/.well-known/host-meta', false, ['timeout' => $xrd_timeout]);
|
$curlResult = DI::httpRequest()->curl($url . '/.well-known/host-meta', false, ['timeout' => $xrd_timeout]);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1009,7 @@ class GServer
|
||||||
{
|
{
|
||||||
$serverdata['poco'] = '';
|
$serverdata['poco'] = '';
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url . '/poco');
|
$curlResult = DI::httpRequest()->curl($url . '/poco');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
}
|
}
|
||||||
|
@ -1039,7 +1039,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
public static function checkMastodonDirectory(string $url, array $serverdata)
|
public static function checkMastodonDirectory(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($url . '/api/v1/directory?limit=1');
|
$curlResult = DI::httpRequest()->curl($url . '/api/v1/directory?limit=1');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
}
|
}
|
||||||
|
@ -1066,7 +1066,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function detectNextcloud(string $url, array $serverdata)
|
private static function detectNextcloud(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($url . '/status.php');
|
$curlResult = DI::httpRequest()->curl($url . '/status.php');
|
||||||
|
|
||||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
|
@ -1100,7 +1100,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function detectMastodonAlikes(string $url, array $serverdata)
|
private static function detectMastodonAlikes(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($url . '/api/v1/instance');
|
$curlResult = DI::httpRequest()->curl($url . '/api/v1/instance');
|
||||||
|
|
||||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
|
@ -1166,7 +1166,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function detectHubzilla(string $url, array $serverdata)
|
private static function detectHubzilla(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($url . '/api/statusnet/config.json');
|
$curlResult = DI::httpRequest()->curl($url . '/api/statusnet/config.json');
|
||||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
}
|
}
|
||||||
|
@ -1264,7 +1264,7 @@ class GServer
|
||||||
private static function detectGNUSocial(string $url, array $serverdata)
|
private static function detectGNUSocial(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
// Test for GNU Social
|
// Test for GNU Social
|
||||||
$curlResult = HTTPRequest::curl($url . '/api/gnusocial/version.json');
|
$curlResult = DI::httpRequest()->curl($url . '/api/gnusocial/version.json');
|
||||||
if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
|
if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
|
||||||
($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
|
($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
|
||||||
$serverdata['platform'] = 'gnusocial';
|
$serverdata['platform'] = 'gnusocial';
|
||||||
|
@ -1282,7 +1282,7 @@ class GServer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for Statusnet
|
// Test for Statusnet
|
||||||
$curlResult = HTTPRequest::curl($url . '/api/statusnet/version.json');
|
$curlResult = DI::httpRequest()->curl($url . '/api/statusnet/version.json');
|
||||||
if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
|
if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
|
||||||
($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
|
($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
|
||||||
|
|
||||||
|
@ -1318,9 +1318,9 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function detectFriendica(string $url, array $serverdata)
|
private static function detectFriendica(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($url . '/friendica/json');
|
$curlResult = DI::httpRequest()->curl($url . '/friendica/json');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
$curlResult = HTTPRequest::curl($url . '/friendika/json');
|
$curlResult = DI::httpRequest()->curl($url . '/friendika/json');
|
||||||
$friendika = true;
|
$friendika = true;
|
||||||
$platform = 'Friendika';
|
$platform = 'Friendika';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1653,7 +1653,7 @@ class GServer
|
||||||
if (!empty($accesstoken)) {
|
if (!empty($accesstoken)) {
|
||||||
$api = 'https://instances.social/api/1.0/instances/list?count=0';
|
$api = 'https://instances.social/api/1.0/instances/list?count=0';
|
||||||
$header = ['Authorization: Bearer '.$accesstoken];
|
$header = ['Authorization: Bearer '.$accesstoken];
|
||||||
$curlResult = HTTPRequest::curl($api, false, ['headers' => $header]);
|
$curlResult = DI::httpRequest()->curl($api, false, ['headers' => $header]);
|
||||||
|
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$servers = json_decode($curlResult->getBody(), true);
|
$servers = json_decode($curlResult->getBody(), true);
|
||||||
|
|
|
@ -28,7 +28,6 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBStructure;
|
use Friendica\Database\DBStructure;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Storage\SystemResource;
|
use Friendica\Model\Storage\SystemResource;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Images;
|
use Friendica\Util\Images;
|
||||||
|
@ -421,7 +420,7 @@ class Photo
|
||||||
|
|
||||||
$filename = basename($image_url);
|
$filename = basename($image_url);
|
||||||
if (!empty($image_url)) {
|
if (!empty($image_url)) {
|
||||||
$ret = HTTPRequest::curl($image_url, true);
|
$ret = DI::httpRequest()->curl($image_url, true);
|
||||||
$img_str = $ret->getBody();
|
$img_str = $ret->getBody();
|
||||||
$type = $ret->getContentType();
|
$type = $ret->getContentType();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,7 +33,6 @@ use Friendica\Core\Session;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Protocol\Diaspora;
|
use Friendica\Protocol\Diaspora;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
@ -738,7 +737,7 @@ class Profile
|
||||||
$magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request;
|
$magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request;
|
||||||
|
|
||||||
// We have to check if the remote server does understand /magic without invoking something
|
// We have to check if the remote server does understand /magic without invoking something
|
||||||
$serverret = HTTPRequest::curl($basepath . '/magic');
|
$serverret = DI::httpRequest()->curl($basepath . '/magic');
|
||||||
if ($serverret->isSuccess()) {
|
if ($serverret->isSuccess()) {
|
||||||
Logger::log('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, Logger::DEBUG);
|
Logger::log('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, Logger::DEBUG);
|
||||||
System::externalRedirect($magic_path);
|
System::externalRedirect($magic_path);
|
||||||
|
|
|
@ -32,7 +32,6 @@ use Friendica\DI;
|
||||||
use Friendica\Model\Register;
|
use Friendica\Model\Register;
|
||||||
use Friendica\Module\BaseAdmin;
|
use Friendica\Module\BaseAdmin;
|
||||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
use Friendica\Util\ConfigFileLoader;
|
use Friendica\Util\ConfigFileLoader;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
|
@ -247,7 +246,7 @@ class Summary extends BaseAdmin
|
||||||
private static function checkSelfHostMeta()
|
private static function checkSelfHostMeta()
|
||||||
{
|
{
|
||||||
// Fetch the host-meta to check if this really is a vital server
|
// Fetch the host-meta to check if this really is a vital server
|
||||||
return HTTPRequest::curl(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess();
|
return DI::httpRequest()->curl(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Util\HTTPSignature;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -101,7 +100,7 @@ class Magic extends BaseModule
|
||||||
);
|
);
|
||||||
|
|
||||||
// Try to get an authentication token from the other instance.
|
// Try to get an authentication token from the other instance.
|
||||||
$curlResult = HTTPRequest::curl($basepath . '/owa', false, ['headers' => $headers]);
|
$curlResult = DI::httpRequest()->curl($basepath . '/owa', false, ['headers' => $headers]);
|
||||||
|
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$j = json_decode($curlResult->getBody(), true);
|
$j = json_decode($curlResult->getBody(), true);
|
||||||
|
|
|
@ -71,12 +71,12 @@ class HTTPRequest
|
||||||
* @return CurlResult
|
* @return CurlResult
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function curl(string $url, bool $binary = false, array $opts = [], int &$redirects = 0)
|
public function curl(string $url, bool $binary = false, array $opts = [], int &$redirects = 0)
|
||||||
{
|
{
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
if (strlen($url) > 1000) {
|
if (strlen($url) > 1000) {
|
||||||
Logger::log('URL is longer than 1000 characters. Callstack: ' . System::callstack(20), Logger::DEBUG);
|
$this->logger->debug('URL is longer than 1000 characters.', ['url' => $url, 'callstack' => System::callstack(20)]);
|
||||||
return CurlResult::createErrorCurl(substr($url, 0, 200));
|
return CurlResult::createErrorCurl(substr($url, 0, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ class HTTPRequest
|
||||||
$url = Network::unparseURL($parts);
|
$url = Network::unparseURL($parts);
|
||||||
|
|
||||||
if (Network::isUrlBlocked($url)) {
|
if (Network::isUrlBlocked($url)) {
|
||||||
Logger::log('domain of ' . $url . ' is blocked', Logger::DATA);
|
$this->logger->info('Domain is blocked.', ['url' => $url]);
|
||||||
return CurlResult::createErrorCurl($url);
|
return CurlResult::createErrorCurl($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,9 +128,9 @@ class HTTPRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent());
|
@curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
|
||||||
|
|
||||||
$range = intval(DI::config()->get('system', 'curl_range_bytes', 0));
|
$range = intval($this->config->get('system', 'curl_range_bytes', 0));
|
||||||
|
|
||||||
if ($range > 0) {
|
if ($range > 0) {
|
||||||
@curl_setopt($ch, CURLOPT_RANGE, '0-' . $range);
|
@curl_setopt($ch, CURLOPT_RANGE, '0-' . $range);
|
||||||
|
@ -152,33 +152,33 @@ class HTTPRequest
|
||||||
if (!empty($opts['timeout'])) {
|
if (!empty($opts['timeout'])) {
|
||||||
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
|
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
|
||||||
} else {
|
} else {
|
||||||
$curl_time = DI::config()->get('system', 'curl_timeout', 60);
|
$curl_time = $this->config->get('system', 'curl_timeout', 60);
|
||||||
@curl_setopt($ch, CURLOPT_TIMEOUT, intval($curl_time));
|
@curl_setopt($ch, CURLOPT_TIMEOUT, intval($curl_time));
|
||||||
}
|
}
|
||||||
|
|
||||||
// by default we will allow self-signed certs
|
// by default we will allow self-signed certs
|
||||||
// but you can override this
|
// but you can override this
|
||||||
|
|
||||||
$check_cert = DI::config()->get('system', 'verifyssl');
|
$check_cert = $this->config->get('system', 'verifyssl');
|
||||||
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
|
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
|
||||||
|
|
||||||
if ($check_cert) {
|
if ($check_cert) {
|
||||||
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
$proxy = DI::config()->get('system', 'proxy');
|
$proxy = $this->config->get('system', 'proxy');
|
||||||
|
|
||||||
if (strlen($proxy)) {
|
if (!empty($proxy)) {
|
||||||
@curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
|
@curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
|
||||||
@curl_setopt($ch, CURLOPT_PROXY, $proxy);
|
@curl_setopt($ch, CURLOPT_PROXY, $proxy);
|
||||||
$proxyuser = @DI::config()->get('system', 'proxyuser');
|
$proxyuser = $this->config->get('system', 'proxyuser');
|
||||||
|
|
||||||
if (strlen($proxyuser)) {
|
if (!empty($proxyuser)) {
|
||||||
@curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyuser);
|
@curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyuser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::config()->get('system', 'ipv4_resolve', false)) {
|
if ($this->config->get('system', 'ipv4_resolve', false)) {
|
||||||
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,14 +204,14 @@ class HTTPRequest
|
||||||
|
|
||||||
if ($curlResponse->isRedirectUrl()) {
|
if ($curlResponse->isRedirectUrl()) {
|
||||||
$redirects++;
|
$redirects++;
|
||||||
Logger::log('curl: redirect ' . $url . ' to ' . $curlResponse->getRedirectUrl());
|
$this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
|
||||||
@curl_close($ch);
|
@curl_close($ch);
|
||||||
return self::curl($curlResponse->getRedirectUrl(), $binary, $opts, $redirects);
|
return self::curl($curlResponse->getRedirectUrl(), $binary, $opts, $redirects);
|
||||||
}
|
}
|
||||||
|
|
||||||
@curl_close($ch);
|
@curl_close($ch);
|
||||||
|
|
||||||
DI::profiler()->saveTimestamp($stamp1, 'network', System::callstack());
|
$this->profiler->saveTimestamp($stamp1, 'network', System::callstack());
|
||||||
|
|
||||||
return $curlResponse;
|
return $curlResponse;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ class Probe
|
||||||
Logger::info('Probing', ['host' => $host, 'ssl_url' => $ssl_url, 'url' => $url, 'callstack' => System::callstack(20)]);
|
Logger::info('Probing', ['host' => $host, 'ssl_url' => $ssl_url, 'url' => $url, 'callstack' => System::callstack(20)]);
|
||||||
$xrd = null;
|
$xrd = null;
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($ssl_url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
$curlResult = DI::httpRequest()->curl($ssl_url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
||||||
$ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
|
$ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$xml = $curlResult->getBody();
|
$xml = $curlResult->getBody();
|
||||||
|
@ -183,7 +183,7 @@ class Probe
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_object($xrd) && !empty($url)) {
|
if (!is_object($xrd) && !empty($url)) {
|
||||||
$curlResult = HTTPRequest::curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
$curlResult = DI::httpRequest()->curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
||||||
$connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
|
$connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
Logger::info('Probing timeout', ['url' => $url]);
|
Logger::info('Probing timeout', ['url' => $url]);
|
||||||
|
@ -427,7 +427,7 @@ class Probe
|
||||||
*/
|
*/
|
||||||
private static function getHideStatus($url)
|
private static function getHideStatus($url)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -841,7 +841,7 @@ class Probe
|
||||||
|
|
||||||
public static function pollZot($url, $data)
|
public static function pollZot($url, $data)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -938,7 +938,7 @@ class Probe
|
||||||
{
|
{
|
||||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20);
|
$xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20);
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
|
$curlResult = DI::httpRequest()->curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::$istimeout = true;
|
self::$istimeout = true;
|
||||||
return [];
|
return [];
|
||||||
|
@ -1007,7 +1007,7 @@ class Probe
|
||||||
*/
|
*/
|
||||||
private static function pollNoscrape($noscrape_url, $data)
|
private static function pollNoscrape($noscrape_url, $data)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($noscrape_url);
|
$curlResult = DI::httpRequest()->curl($noscrape_url);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::$istimeout = true;
|
self::$istimeout = true;
|
||||||
return [];
|
return [];
|
||||||
|
@ -1265,7 +1265,7 @@ class Probe
|
||||||
*/
|
*/
|
||||||
private static function pollHcard($hcard_url, $data, $dfrn = false)
|
private static function pollHcard($hcard_url, $data, $dfrn = false)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($hcard_url);
|
$curlResult = DI::httpRequest()->curl($hcard_url);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::$istimeout = true;
|
self::$istimeout = true;
|
||||||
return [];
|
return [];
|
||||||
|
@ -1519,7 +1519,7 @@ class Probe
|
||||||
$pubkey = substr($pubkey, 5);
|
$pubkey = substr($pubkey, 5);
|
||||||
}
|
}
|
||||||
} elseif (Strings::normaliseLink($pubkey) == 'http://') {
|
} elseif (Strings::normaliseLink($pubkey) == 'http://') {
|
||||||
$curlResult = HTTPRequest::curl($pubkey);
|
$curlResult = DI::httpRequest()->curl($pubkey);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::$istimeout = true;
|
self::$istimeout = true;
|
||||||
return $short ? false : [];
|
return $short ? false : [];
|
||||||
|
@ -1552,7 +1552,7 @@ class Probe
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch all additional data from the feed
|
// Fetch all additional data from the feed
|
||||||
$curlResult = HTTPRequest::curl($data["poll"]);
|
$curlResult = DI::httpRequest()->curl($data["poll"]);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::$istimeout = true;
|
self::$istimeout = true;
|
||||||
return [];
|
return [];
|
||||||
|
@ -1604,7 +1604,7 @@ class Probe
|
||||||
*/
|
*/
|
||||||
private static function pumpioProfileData($profile_link)
|
private static function pumpioProfileData($profile_link)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($profile_link);
|
$curlResult = DI::httpRequest()->curl($profile_link);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -1835,7 +1835,7 @@ class Probe
|
||||||
*/
|
*/
|
||||||
private static function feed($url, $probe = true)
|
private static function feed($url, $probe = true)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::$istimeout = true;
|
self::$istimeout = true;
|
||||||
return [];
|
return [];
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Protocol;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Model\APContact;
|
use Friendica\Model\APContact;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Util\HTTPSignature;
|
||||||
use Friendica\Util\JsonLD;
|
use Friendica\Util\JsonLD;
|
||||||
|
|
||||||
|
@ -93,7 +92,7 @@ class ActivityPub
|
||||||
return HTTPSignature::fetch($url, $uid);
|
return HTTPSignature::fetch($url, $uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url, false, ['accept_content' => 'application/activity+json, application/ld+json']);
|
$curlResult = DI::httpRequest()->curl($url, false, ['accept_content' => 'application/activity+json, application/ld+json']);
|
||||||
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
|
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1195,7 +1195,7 @@ class DFRN
|
||||||
|
|
||||||
Logger::log('dfrn_deliver: ' . $url);
|
Logger::log('dfrn_deliver: ' . $url);
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
|
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
return -2; // timed out
|
return -2; // timed out
|
||||||
|
|
|
@ -39,7 +39,6 @@ use Friendica\Model\Item;
|
||||||
use Friendica\Model\ItemURI;
|
use Friendica\Model\ItemURI;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Images;
|
use Friendica\Util\Images;
|
||||||
|
@ -756,7 +755,7 @@ class OStatus
|
||||||
|
|
||||||
self::$conv_list[$conversation] = true;
|
self::$conv_list[$conversation] = true;
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
|
$curlResult = DI::httpRequest()->curl($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return;
|
return;
|
||||||
|
@ -785,7 +784,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($file != '') {
|
if ($file != '') {
|
||||||
$conversation_atom = HTTPRequest::curl($attribute['href']);
|
$conversation_atom = DI::httpRequest()->curl($attribute['href']);
|
||||||
|
|
||||||
if ($conversation_atom->isSuccess()) {
|
if ($conversation_atom->isSuccess()) {
|
||||||
$xml = $conversation_atom->getBody();
|
$xml = $conversation_atom->getBody();
|
||||||
|
@ -902,7 +901,7 @@ class OStatus
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($self);
|
$curlResult = DI::httpRequest()->curl($self);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return;
|
return;
|
||||||
|
@ -949,7 +948,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
$stored = false;
|
$stored = false;
|
||||||
$curlResult = HTTPRequest::curl($related, false, ['accept_content' => 'application/atom+xml, text/html']);
|
$curlResult = DI::httpRequest()->curl($related, false, ['accept_content' => 'application/atom+xml, text/html']);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return;
|
return;
|
||||||
|
@ -980,7 +979,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($atom_file != '') {
|
if ($atom_file != '') {
|
||||||
$curlResult = HTTPRequest::curl($atom_file);
|
$curlResult = DI::httpRequest()->curl($atom_file);
|
||||||
|
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
Logger::log('Fetched XML for URI ' . $related_uri, Logger::DEBUG);
|
Logger::log('Fetched XML for URI ' . $related_uri, Logger::DEBUG);
|
||||||
|
@ -992,7 +991,7 @@ class OStatus
|
||||||
|
|
||||||
// Workaround for older GNU Social servers
|
// Workaround for older GNU Social servers
|
||||||
if (($xml == '') && strstr($related, '/notice/')) {
|
if (($xml == '') && strstr($related, '/notice/')) {
|
||||||
$curlResult = HTTPRequest::curl(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom');
|
$curlResult = DI::httpRequest()->curl(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom');
|
||||||
|
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
Logger::log('GNU Social workaround to fetch XML for URI ' . $related_uri, Logger::DEBUG);
|
Logger::log('GNU Social workaround to fetch XML for URI ' . $related_uri, Logger::DEBUG);
|
||||||
|
@ -1003,7 +1002,7 @@ class OStatus
|
||||||
// Even more worse workaround for GNU Social ;-)
|
// Even more worse workaround for GNU Social ;-)
|
||||||
if ($xml == '') {
|
if ($xml == '') {
|
||||||
$related_guess = self::convertHref($related_uri);
|
$related_guess = self::convertHref($related_uri);
|
||||||
$curlResult = HTTPRequest::curl(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom');
|
$curlResult = DI::httpRequest()->curl(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom');
|
||||||
|
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
Logger::log('GNU Social workaround 2 to fetch XML for URI ' . $related_uri, Logger::DEBUG);
|
Logger::log('GNU Social workaround 2 to fetch XML for URI ' . $related_uri, Logger::DEBUG);
|
||||||
|
|
|
@ -251,7 +251,7 @@ class PortableContact
|
||||||
*/
|
*/
|
||||||
private static function fetchServerlist($poco)
|
private static function fetchServerlist($poco)
|
||||||
{
|
{
|
||||||
$curlResult = HTTPRequest::curl($poco . "/@server");
|
$curlResult = DI::httpRequest()->curl($poco . "/@server");
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return;
|
return;
|
||||||
|
@ -291,7 +291,7 @@ class PortableContact
|
||||||
|
|
||||||
Logger::info("Fetch all users from the server " . $server["url"]);
|
Logger::info("Fetch all users from the server " . $server["url"]);
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
|
|
||||||
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
|
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
|
||||||
$data = json_decode($curlResult->getBody(), true);
|
$data = json_decode($curlResult->getBody(), true);
|
||||||
|
@ -314,7 +314,7 @@ class PortableContact
|
||||||
|
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
|
|
||||||
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
|
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
|
||||||
Logger::info("Fetch all global contacts from the server " . $server["nurl"]);
|
Logger::info("Fetch all global contacts from the server " . $server["nurl"]);
|
||||||
|
@ -372,7 +372,7 @@ class PortableContact
|
||||||
// Fetch all contacts from a given user from the other server
|
// Fetch all contacts from a given user from the other server
|
||||||
$url = $server['poco'] . '/' . $username . '/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,contactType,generation';
|
$url = $server['poco'] . '/' . $username . '/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,contactType,generation';
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
|
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$data = json_decode($curlResult->getBody(), true);
|
$data = json_decode($curlResult->getBody(), true);
|
||||||
|
|
|
@ -37,7 +37,6 @@ namespace Friendica\Util;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
|
|
||||||
class ExAuth
|
class ExAuth
|
||||||
{
|
{
|
||||||
|
@ -182,7 +181,7 @@ class ExAuth
|
||||||
|
|
||||||
$url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user;
|
$url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user;
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -443,7 +443,7 @@ class HTTPSignature
|
||||||
$curl_opts = $opts;
|
$curl_opts = $opts;
|
||||||
$curl_opts['header'] = $headers;
|
$curl_opts['header'] = $headers;
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($request, false, $curl_opts);
|
$curlResult = DI::httpRequest()->curl($request, false, $curl_opts);
|
||||||
$return_code = $curlResult->getReturnCode();
|
$return_code = $curlResult->getReturnCode();
|
||||||
|
|
||||||
Logger::log('Fetched for user ' . $uid . ' from ' . $request . ' returned ' . $return_code, Logger::DEBUG);
|
Logger::log('Fetched for user ' . $uid . ' from ' . $request . ' returned ' . $return_code, Logger::DEBUG);
|
||||||
|
|
|
@ -27,7 +27,6 @@ use Friendica\Content\OEmbed;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about a given URL
|
* Get information about a given URL
|
||||||
|
@ -160,7 +159,7 @@ class ParseUrl
|
||||||
return $siteinfo;
|
return $siteinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return $siteinfo;
|
return $siteinfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,7 @@ class OnePoll
|
||||||
. '&type=data&last_update=' . $last_update
|
. '&type=data&last_update=' . $last_update
|
||||||
. '&perm=' . $perm;
|
. '&perm=' . $perm;
|
||||||
|
|
||||||
$curlResult = HTTPRequest::curl($url);
|
$curlResult = DI::httpRequest()->curl($url);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess() && ($curlResult->getErrorNumber() == CURLE_OPERATION_TIMEDOUT)) {
|
if (!$curlResult->isSuccess() && ($curlResult->getErrorNumber() == CURLE_OPERATION_TIMEDOUT)) {
|
||||||
// set the last-update so we don't keep polling
|
// set the last-update so we don't keep polling
|
||||||
|
@ -444,7 +444,7 @@ class OnePoll
|
||||||
}
|
}
|
||||||
|
|
||||||
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
|
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
|
||||||
$curlResult = HTTPRequest::curl($contact['poll'], false, ['cookiejar' => $cookiejar]);
|
$curlResult = DI::httpRequest()->curl($contact['poll'], false, ['cookiejar' => $cookiejar]);
|
||||||
unlink($cookiejar);
|
unlink($cookiejar);
|
||||||
|
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user