Rename "HTTPRequest::curl()" to HTTPRequest::get()
This commit is contained in:
parent
e5649d6dbf
commit
7029012f27
|
@ -54,7 +54,7 @@ function ostatus_subscribe_content(App $a)
|
||||||
$api = $contact['baseurl'] . '/api/';
|
$api = $contact['baseurl'] . '/api/';
|
||||||
|
|
||||||
// Fetching friends
|
// Fetching friends
|
||||||
$curlResult = DI::httpRequest()->curl($api . 'statuses/friends.json?screen_name=' . $contact['nick']);
|
$curlResult = DI::httpRequest()->get($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,6 +28,7 @@ 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\DI;
|
||||||
use Friendica\Util\ParseUrl;
|
use Friendica\Util\ParseUrl;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -84,7 +85,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 = DI::httpRequest()->curl($url, false, ['novalidate' => true, 'nobody' => true]);
|
$curlResponse = DI::httpRequest()->get($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
|
||||||
|
|
|
@ -170,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 = DI::httpRequest()->curl($basepath . '/magic');
|
$serverret = DI::httpRequest()->get($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);
|
||||||
|
|
|
@ -485,7 +485,7 @@ class BBCode
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($mtch[1], true);
|
$curlResult = DI::httpRequest()->get($mtch[1], true);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,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 = DI::httpRequest()->curl(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']);
|
$curlResult = DI::httpRequest()->get(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'])) {
|
||||||
|
|
|
@ -844,7 +844,7 @@ class GContact
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($gserver['noscrape'] . '/' . $data['nick']);
|
$curlResult = DI::httpRequest()->get($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);
|
||||||
|
@ -926,7 +926,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 = DI::httpRequest()->curl($data['poll']);
|
$curlResult = DI::httpRequest()->get($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'])]);
|
||||||
|
@ -1204,7 +1204,7 @@ class GContact
|
||||||
|
|
||||||
$url = $server . '/main/statistics';
|
$url = $server . '/main/statistics';
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($url);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,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 = DI::httpRequest()->curl($url . '/.well-known/nodeinfo', false, ['timeout' => $xrd_timeout]);
|
$curlResult = DI::httpRequest()->get($url . '/.well-known/nodeinfo', false, ['timeout' => $xrd_timeout]);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::setFailure($url);
|
self::setFailure($url);
|
||||||
return false;
|
return false;
|
||||||
|
@ -342,7 +342,7 @@ class GServer
|
||||||
$basedata = ['detection-method' => self::DETECT_MANUAL];
|
$basedata = ['detection-method' => self::DETECT_MANUAL];
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($baseurl, false, ['timeout' => $xrd_timeout]);
|
$curlResult = DI::httpRequest()->get($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);
|
||||||
|
@ -498,7 +498,7 @@ class GServer
|
||||||
{
|
{
|
||||||
Logger::info('Discover relay data', ['server' => $server_url]);
|
Logger::info('Discover relay data', ['server' => $server_url]);
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($server_url . '/.well-known/x-social-relay');
|
$curlResult = DI::httpRequest()->get($server_url . '/.well-known/x-social-relay');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -579,7 +579,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function fetchStatistics(string $url)
|
private static function fetchStatistics(string $url)
|
||||||
{
|
{
|
||||||
$curlResult = DI::httpRequest()->curl($url . '/statistics.json');
|
$curlResult = DI::httpRequest()->get($url . '/statistics.json');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -689,7 +689,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function parseNodeinfo1(string $nodeinfo_url)
|
private static function parseNodeinfo1(string $nodeinfo_url)
|
||||||
{
|
{
|
||||||
$curlResult = DI::httpRequest()->curl($nodeinfo_url);
|
$curlResult = DI::httpRequest()->get($nodeinfo_url);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return [];
|
return [];
|
||||||
|
@ -766,7 +766,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function parseNodeinfo2(string $nodeinfo_url)
|
private static function parseNodeinfo2(string $nodeinfo_url)
|
||||||
{
|
{
|
||||||
$curlResult = DI::httpRequest()->curl($nodeinfo_url);
|
$curlResult = DI::httpRequest()->get($nodeinfo_url);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -843,7 +843,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function fetchSiteinfo(string $url, array $serverdata)
|
private static function fetchSiteinfo(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = DI::httpRequest()->curl($url . '/siteinfo.json');
|
$curlResult = DI::httpRequest()->get($url . '/siteinfo.json');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
}
|
}
|
||||||
|
@ -912,7 +912,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 = DI::httpRequest()->curl($url . '/.well-known/host-meta', false, ['timeout' => $xrd_timeout]);
|
$curlResult = DI::httpRequest()->get($url . '/.well-known/host-meta', false, ['timeout' => $xrd_timeout]);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1008,7 +1008,7 @@ class GServer
|
||||||
{
|
{
|
||||||
$serverdata['poco'] = '';
|
$serverdata['poco'] = '';
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($url . '/poco');
|
$curlResult = DI::httpRequest()->get($url . '/poco');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
}
|
}
|
||||||
|
@ -1038,7 +1038,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
public static function checkMastodonDirectory(string $url, array $serverdata)
|
public static function checkMastodonDirectory(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = DI::httpRequest()->curl($url . '/api/v1/directory?limit=1');
|
$curlResult = DI::httpRequest()->get($url . '/api/v1/directory?limit=1');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
}
|
}
|
||||||
|
@ -1065,7 +1065,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function detectNextcloud(string $url, array $serverdata)
|
private static function detectNextcloud(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = DI::httpRequest()->curl($url . '/status.php');
|
$curlResult = DI::httpRequest()->get($url . '/status.php');
|
||||||
|
|
||||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
|
@ -1099,7 +1099,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function detectMastodonAlikes(string $url, array $serverdata)
|
private static function detectMastodonAlikes(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = DI::httpRequest()->curl($url . '/api/v1/instance');
|
$curlResult = DI::httpRequest()->get($url . '/api/v1/instance');
|
||||||
|
|
||||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
|
@ -1165,7 +1165,7 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function detectHubzilla(string $url, array $serverdata)
|
private static function detectHubzilla(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = DI::httpRequest()->curl($url . '/api/statusnet/config.json');
|
$curlResult = DI::httpRequest()->get($url . '/api/statusnet/config.json');
|
||||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
}
|
}
|
||||||
|
@ -1263,7 +1263,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 = DI::httpRequest()->curl($url . '/api/gnusocial/version.json');
|
$curlResult = DI::httpRequest()->get($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';
|
||||||
|
@ -1281,7 +1281,7 @@ class GServer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for Statusnet
|
// Test for Statusnet
|
||||||
$curlResult = DI::httpRequest()->curl($url . '/api/statusnet/version.json');
|
$curlResult = DI::httpRequest()->get($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)) {
|
||||||
|
|
||||||
|
@ -1317,9 +1317,9 @@ class GServer
|
||||||
*/
|
*/
|
||||||
private static function detectFriendica(string $url, array $serverdata)
|
private static function detectFriendica(string $url, array $serverdata)
|
||||||
{
|
{
|
||||||
$curlResult = DI::httpRequest()->curl($url . '/friendica/json');
|
$curlResult = DI::httpRequest()->get($url . '/friendica/json');
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
$curlResult = DI::httpRequest()->curl($url . '/friendika/json');
|
$curlResult = DI::httpRequest()->get($url . '/friendika/json');
|
||||||
$friendika = true;
|
$friendika = true;
|
||||||
$platform = 'Friendika';
|
$platform = 'Friendika';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1652,7 +1652,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 = DI::httpRequest()->curl($api, false, ['headers' => $header]);
|
$curlResult = DI::httpRequest()->get($api, false, ['headers' => $header]);
|
||||||
|
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$servers = json_decode($curlResult->getBody(), true);
|
$servers = json_decode($curlResult->getBody(), true);
|
||||||
|
|
|
@ -420,7 +420,7 @@ class Photo
|
||||||
|
|
||||||
$filename = basename($image_url);
|
$filename = basename($image_url);
|
||||||
if (!empty($image_url)) {
|
if (!empty($image_url)) {
|
||||||
$ret = DI::httpRequest()->curl($image_url, true);
|
$ret = DI::httpRequest()->get($image_url, true);
|
||||||
$img_str = $ret->getBody();
|
$img_str = $ret->getBody();
|
||||||
$type = $ret->getContentType();
|
$type = $ret->getContentType();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -737,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 = DI::httpRequest()->curl($basepath . '/magic');
|
$serverret = DI::httpRequest()->get($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);
|
||||||
|
|
|
@ -823,7 +823,7 @@ class User
|
||||||
$photo_failure = false;
|
$photo_failure = false;
|
||||||
|
|
||||||
$filename = basename($photo);
|
$filename = basename($photo);
|
||||||
$curlResult = DI::httpRequest()->curl($photo, true);
|
$curlResult = DI::httpRequest()->get($photo, true);
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$img_str = $curlResult->getBody();
|
$img_str = $curlResult->getBody();
|
||||||
$type = $curlResult->getContentType();
|
$type = $curlResult->getContentType();
|
||||||
|
|
|
@ -246,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 DI::httpRequest()->curl(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess();
|
return DI::httpRequest()->get(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,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 = DI::httpRequest()->curl($basepath . '/owa', false, ['headers' => $headers]);
|
$curlResult = DI::httpRequest()->get($basepath . '/owa', false, ['headers' => $headers]);
|
||||||
|
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$j = json_decode($curlResult->getBody(), true);
|
$j = json_decode($curlResult->getBody(), true);
|
||||||
|
|
|
@ -71,7 +71,7 @@ class HTTPRequest
|
||||||
* @return CurlResult
|
* @return CurlResult
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function curl(string $url, bool $binary = false, array $opts = [], int &$redirects = 0)
|
public function get(string $url, bool $binary = false, array $opts = [], int &$redirects = 0)
|
||||||
{
|
{
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ class HTTPRequest
|
||||||
$redirects++;
|
$redirects++;
|
||||||
$this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
|
$this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
|
||||||
@curl_close($ch);
|
@curl_close($ch);
|
||||||
return $this->curl($curlResponse->getRedirectUrl(), $binary, $opts, $redirects);
|
return $this->get($curlResponse->getRedirectUrl(), $binary, $opts, $redirects);
|
||||||
}
|
}
|
||||||
|
|
||||||
@curl_close($ch);
|
@curl_close($ch);
|
||||||
|
@ -486,7 +486,7 @@ class HTTPRequest
|
||||||
*/
|
*/
|
||||||
public function fetchUrlFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
|
public function fetchUrlFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
|
||||||
{
|
{
|
||||||
return $this->curl(
|
return $this->get(
|
||||||
$url,
|
$url,
|
||||||
$binary,
|
$binary,
|
||||||
[
|
[
|
||||||
|
|
|
@ -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 = DI::httpRequest()->curl($ssl_url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
$curlResult = DI::httpRequest()->get($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 = DI::httpRequest()->curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
$curlResult = DI::httpRequest()->get($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 = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($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 = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($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 = DI::httpRequest()->curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
|
$curlResult = DI::httpRequest()->get($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 = DI::httpRequest()->curl($noscrape_url);
|
$curlResult = DI::httpRequest()->get($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 = DI::httpRequest()->curl($hcard_url);
|
$curlResult = DI::httpRequest()->get($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 = DI::httpRequest()->curl($pubkey);
|
$curlResult = DI::httpRequest()->get($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 = DI::httpRequest()->curl($data["poll"]);
|
$curlResult = DI::httpRequest()->get($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 = DI::httpRequest()->curl($profile_link);
|
$curlResult = DI::httpRequest()->get($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 = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($url);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::$istimeout = true;
|
self::$istimeout = true;
|
||||||
return [];
|
return [];
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
namespace Friendica\Protocol;
|
namespace Friendica\Protocol;
|
||||||
|
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Model\APContact;
|
use Friendica\Model\APContact;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Util\HTTPSignature;
|
||||||
|
@ -92,7 +93,7 @@ class ActivityPub
|
||||||
return HTTPSignature::fetch($url, $uid);
|
return HTTPSignature::fetch($url, $uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($url, false, ['accept_content' => 'application/activity+json, application/ld+json']);
|
$curlResult = DI::httpRequest()->get($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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1194,7 +1194,7 @@ class DFRN
|
||||||
|
|
||||||
Logger::log('dfrn_deliver: ' . $url);
|
Logger::log('dfrn_deliver: ' . $url);
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($url);
|
||||||
|
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
return -2; // timed out
|
return -2; // timed out
|
||||||
|
|
|
@ -755,7 +755,7 @@ class OStatus
|
||||||
|
|
||||||
self::$conv_list[$conversation] = true;
|
self::$conv_list[$conversation] = true;
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
|
$curlResult = DI::httpRequest()->get($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return;
|
return;
|
||||||
|
@ -784,7 +784,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($file != '') {
|
if ($file != '') {
|
||||||
$conversation_atom = DI::httpRequest()->curl($attribute['href']);
|
$conversation_atom = DI::httpRequest()->get($attribute['href']);
|
||||||
|
|
||||||
if ($conversation_atom->isSuccess()) {
|
if ($conversation_atom->isSuccess()) {
|
||||||
$xml = $conversation_atom->getBody();
|
$xml = $conversation_atom->getBody();
|
||||||
|
@ -901,7 +901,7 @@ class OStatus
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($self);
|
$curlResult = DI::httpRequest()->get($self);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return;
|
return;
|
||||||
|
@ -948,7 +948,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
$stored = false;
|
$stored = false;
|
||||||
$curlResult = DI::httpRequest()->curl($related, false, ['accept_content' => 'application/atom+xml, text/html']);
|
$curlResult = DI::httpRequest()->get($related, false, ['accept_content' => 'application/atom+xml, text/html']);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return;
|
return;
|
||||||
|
@ -979,7 +979,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($atom_file != '') {
|
if ($atom_file != '') {
|
||||||
$curlResult = DI::httpRequest()->curl($atom_file);
|
$curlResult = DI::httpRequest()->get($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);
|
||||||
|
@ -991,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 = DI::httpRequest()->curl(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom');
|
$curlResult = DI::httpRequest()->get(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);
|
||||||
|
@ -1002,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 = DI::httpRequest()->curl(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom');
|
$curlResult = DI::httpRequest()->get(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);
|
||||||
|
|
|
@ -30,7 +30,6 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Model\GServer;
|
use Friendica\Model\GServer;
|
||||||
use Friendica\Network\HTTPRequest;
|
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -251,7 +250,7 @@ class PortableContact
|
||||||
*/
|
*/
|
||||||
private static function fetchServerlist($poco)
|
private static function fetchServerlist($poco)
|
||||||
{
|
{
|
||||||
$curlResult = DI::httpRequest()->curl($poco . "/@server");
|
$curlResult = DI::httpRequest()->get($poco . "/@server");
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return;
|
return;
|
||||||
|
@ -291,7 +290,7 @@ class PortableContact
|
||||||
|
|
||||||
Logger::info("Fetch all users from the server " . $server["url"]);
|
Logger::info("Fetch all users from the server " . $server["url"]);
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($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 +313,7 @@ class PortableContact
|
||||||
|
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($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 +371,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 = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($url);
|
||||||
|
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$data = json_decode($curlResult->getBody(), true);
|
$data = json_decode($curlResult->getBody(), true);
|
||||||
|
|
|
@ -181,7 +181,7 @@ class ExAuth
|
||||||
|
|
||||||
$url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user;
|
$url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user;
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($url);
|
||||||
|
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -442,7 +442,7 @@ class HTTPSignature
|
||||||
$curl_opts = $opts;
|
$curl_opts = $opts;
|
||||||
$curl_opts['header'] = $headers;
|
$curl_opts['header'] = $headers;
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($request, false, $curl_opts);
|
$curlResult = DI::httpRequest()->get($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,6 +27,7 @@ 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\DI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about a given URL
|
* Get information about a given URL
|
||||||
|
@ -159,7 +160,7 @@ class ParseUrl
|
||||||
return $siteinfo;
|
return $siteinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($url);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return $siteinfo;
|
return $siteinfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,7 +290,7 @@ class OnePoll
|
||||||
. '&type=data&last_update=' . $last_update
|
. '&type=data&last_update=' . $last_update
|
||||||
. '&perm=' . $perm;
|
. '&perm=' . $perm;
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->curl($url);
|
$curlResult = DI::httpRequest()->get($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
|
||||||
|
@ -443,7 +443,7 @@ class OnePoll
|
||||||
}
|
}
|
||||||
|
|
||||||
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
|
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
|
||||||
$curlResult = DI::httpRequest()->curl($contact['poll'], false, ['cookiejar' => $cookiejar]);
|
$curlResult = DI::httpRequest()->get($contact['poll'], false, ['cookiejar' => $cookiejar]);
|
||||||
unlink($cookiejar);
|
unlink($cookiejar);
|
||||||
|
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user