Rename "fetchUrl" and "fetchUrlFull" to "fetch" and "fetchFull"

This commit is contained in:
nupplaPhil 2020-03-04 22:35:40 +01:00 committed by Hypolite Petovan
parent 7029012f27
commit 657d08f09f
20 changed files with 32 additions and 34 deletions

View file

@ -114,7 +114,7 @@ function dfrn_poll_init(App $a)
); );
if (DBA::isResult($r)) { if (DBA::isResult($r)) {
$s = DI::httpRequest()->fetchUrl($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check'); $s = DI::httpRequest()->fetch($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
Logger::log("dfrn_poll: old profile returns " . $s, Logger::DATA); Logger::log("dfrn_poll: old profile returns " . $s, Logger::DATA);
@ -498,12 +498,12 @@ function dfrn_poll_content(App $a)
// URL reply // URL reply
if ($dfrn_version < 2.2) { if ($dfrn_version < 2.2) {
$s = DI::httpRequest()->fetchUrl($r[0]['poll'] $s = DI::httpRequest()->fetch($r[0]['poll']
. '?dfrn_id=' . $encrypted_id . '?dfrn_id=' . $encrypted_id
. '&type=profile-check' . '&type=profile-check'
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&dfrn_version=' . DFRN_PROTOCOL_VERSION
. '&challenge=' . $challenge . '&challenge=' . $challenge
. '&sec=' . $sec . '&sec=' . $sec
); );
} else { } else {
$s = DI::httpRequest()->post($r[0]['poll'], [ $s = DI::httpRequest()->post($r[0]['poll'], [

View file

@ -203,7 +203,7 @@ function dfrn_request_post(App $a)
} }
if (!empty($dfrn_request) && strlen($confirm_key)) { if (!empty($dfrn_request) && strlen($confirm_key)) {
DI::httpRequest()->fetchUrl($dfrn_request . '?confirm_key=' . $confirm_key); DI::httpRequest()->fetch($dfrn_request . '?confirm_key=' . $confirm_key);
} }
// (ignore reply, nothing we can do it failed) // (ignore reply, nothing we can do it failed)

View file

@ -57,7 +57,7 @@ function oexchange_content(App $a) {
$tags = ((!empty($_REQUEST['tags'])) $tags = ((!empty($_REQUEST['tags']))
? '&tags=' . urlencode(Strings::escapeTags(trim($_REQUEST['tags']))) : ''); ? '&tags=' . urlencode(Strings::escapeTags(trim($_REQUEST['tags']))) : '');
$s = DI::httpRequest()->fetchUrl(DI::baseUrl() . '/parse_url?url=' . $url . $title . $description . $tags); $s = DI::httpRequest()->fetch(DI::baseUrl() . '/parse_url?url=' . $url . $title . $description . $tags);
if (!strlen($s)) { if (!strlen($s)) {
return; return;

View file

@ -24,7 +24,6 @@ use Friendica\Core\Logger;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\PushSubscriber; use Friendica\Model\PushSubscriber;
use Friendica\Network\HTTPRequest;
use Friendica\Util\Strings; use Friendica\Util\Strings;
function post_var($name) { function post_var($name) {
@ -126,7 +125,7 @@ function pubsubhubbub_init(App $a) {
$hub_callback = rtrim($hub_callback, ' ?&#'); $hub_callback = rtrim($hub_callback, ' ?&#');
$separator = parse_url($hub_callback, PHP_URL_QUERY) === null ? '?' : '&'; $separator = parse_url($hub_callback, PHP_URL_QUERY) === null ? '?' : '&';
$fetchResult = DI::httpRequest()->fetchUrlFull($hub_callback . $separator . $params); $fetchResult = DI::httpRequest()->fetchFull($hub_callback . $separator . $params);
$body = $fetchResult->getBody(); $body = $fetchResult->getBody();
$ret = $fetchResult->getReturnCode(); $ret = $fetchResult->getReturnCode();

View file

@ -95,7 +95,7 @@ class OEmbed
if (!in_array($ext, $noexts)) { if (!in_array($ext, $noexts)) {
// try oembed autodiscovery // try oembed autodiscovery
$html_text = DI::httpRequest()->fetchUrl($embedurl, false, 15, 'text/*'); $html_text = DI::httpRequest()->fetch($embedurl, false, 15, 'text/*');
if ($html_text) { if ($html_text) {
$dom = @DOMDocument::loadHTML($html_text); $dom = @DOMDocument::loadHTML($html_text);
if ($dom) { if ($dom) {
@ -103,14 +103,14 @@ class OEmbed
$entries = $xpath->query("//link[@type='application/json+oembed']"); $entries = $xpath->query("//link[@type='application/json+oembed']");
foreach ($entries as $e) { foreach ($entries as $e) {
$href = $e->getAttributeNode('href')->nodeValue; $href = $e->getAttributeNode('href')->nodeValue;
$json_string = DI::httpRequest()->fetchUrl($href . '&maxwidth=' . $a->videowidth); $json_string = DI::httpRequest()->fetch($href . '&maxwidth=' . $a->videowidth);
break; break;
} }
$entries = $xpath->query("//link[@type='text/json+oembed']"); $entries = $xpath->query("//link[@type='text/json+oembed']");
foreach ($entries as $e) { foreach ($entries as $e) {
$href = $e->getAttributeNode('href')->nodeValue; $href = $e->getAttributeNode('href')->nodeValue;
$json_string = DI::httpRequest()->fetchUrl($href . '&maxwidth=' . $a->videowidth); $json_string = DI::httpRequest()->fetch($href . '&maxwidth=' . $a->videowidth);
break; break;
} }
} }

View file

@ -1106,7 +1106,7 @@ class BBCode
$text = "[url=" . $match[2] . ']' . $match[2] . "[/url]"; $text = "[url=" . $match[2] . ']' . $match[2] . "[/url]";
// if its not a picture then look if its a page that contains a picture link // if its not a picture then look if its a page that contains a picture link
$body = DI::httpRequest()->fetchUrl($match[1]); $body = DI::httpRequest()->fetch($match[1]);
$doc = new DOMDocument(); $doc = new DOMDocument();
@$doc->loadHTML($body); @$doc->loadHTML($body);
@ -1185,7 +1185,7 @@ class BBCode
} }
// if its not a picture then look if its a page that contains a picture link // if its not a picture then look if its a page that contains a picture link
$body = DI::httpRequest()->fetchUrl($match[1]); $body = DI::httpRequest()->fetch($match[1]);
$doc = new DOMDocument(); $doc = new DOMDocument();
@$doc->loadHTML($body); @$doc->loadHTML($body);

View file

@ -27,7 +27,6 @@ use Friendica\Core\Config\Cache;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\DI; use Friendica\DI;
use Friendica\Network\HTTPRequest;
use Friendica\Util\Images; use Friendica\Util\Images;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -548,11 +547,11 @@ class Installer
$help = ""; $help = "";
$error_msg = ""; $error_msg = "";
if (function_exists('curl_init')) { if (function_exists('curl_init')) {
$fetchResult = DI::httpRequest()->fetchUrlFull($baseurl . "/install/testrewrite"); $fetchResult = DI::httpRequest()->fetchFull($baseurl . "/install/testrewrite");
$url = Strings::normaliseLink($baseurl . "/install/testrewrite"); $url = Strings::normaliseLink($baseurl . "/install/testrewrite");
if ($fetchResult->getReturnCode() != 204) { if ($fetchResult->getReturnCode() != 204) {
$fetchResult = DI::httpRequest()->fetchUrlFull($url); $fetchResult = DI::httpRequest()->fetchFull($url);
} }
if ($fetchResult->getReturnCode() != 204) { if ($fetchResult->getReturnCode() != 204) {

View file

@ -123,7 +123,7 @@ class Search
$searchUrl .= '&page=' . $page; $searchUrl .= '&page=' . $page;
} }
$resultJson = DI::httpRequest()->fetchUrl($searchUrl, false, 0, 'application/json'); $resultJson = DI::httpRequest()->fetch($searchUrl, false, 0, 'application/json');
$results = json_decode($resultJson, true); $results = json_decode($resultJson, true);

View file

@ -996,7 +996,7 @@ class Worker
} }
$url = DI::baseUrl() . '/worker'; $url = DI::baseUrl() . '/worker';
DI::httpRequest()->fetchUrl($url, false, 1); DI::httpRequest()->fetch($url, false, 1);
} }
/** /**

View file

@ -536,7 +536,7 @@ class GContact
$done[] = DI::baseUrl() . '/poco'; $done[] = DI::baseUrl() . '/poco';
if (strlen(DI::config()->get('system', 'directory'))) { if (strlen(DI::config()->get('system', 'directory'))) {
$x = DI::httpRequest()->fetchUrl(Search::getGlobalDirectory() . '/pubsites'); $x = DI::httpRequest()->fetch(Search::getGlobalDirectory() . '/pubsites');
if (!empty($x)) { if (!empty($x)) {
$j = json_decode($x); $j = json_decode($x);
if (!empty($j->entries)) { if (!empty($j->entries)) {

View file

@ -1634,7 +1634,7 @@ class GServer
$protocols = ['activitypub', 'diaspora', 'dfrn', 'ostatus']; $protocols = ['activitypub', 'diaspora', 'dfrn', 'ostatus'];
foreach ($protocols as $protocol) { foreach ($protocols as $protocol) {
$query = '{nodes(protocol:"' . $protocol . '"){host}}'; $query = '{nodes(protocol:"' . $protocol . '"){host}}';
$curlResult = DI::httpRequest()->fetchUrl('https://the-federation.info/graphql?query=' . urlencode($query)); $curlResult = DI::httpRequest()->fetch('https://the-federation.info/graphql?query=' . urlencode($query));
if (!empty($curlResult)) { if (!empty($curlResult)) {
$data = json_decode($curlResult, true); $data = json_decode($curlResult, true);
if (!empty($data['data']['nodes'])) { if (!empty($data['data']['nodes'])) {

View file

@ -48,7 +48,7 @@ class Feed extends BaseModule
$contact = Model\Contact::getByURLForUser($url, local_user(), false); $contact = Model\Contact::getByURLForUser($url, local_user(), false);
$xml = DI::httpRequest()->fetchUrl($contact['poll']); $xml = DI::httpRequest()->fetch($contact['poll']);
$import_result = Protocol\Feed::import($xml); $import_result = Protocol\Feed::import($xml);

View file

@ -460,9 +460,9 @@ class HTTPRequest
* @return string The fetched content * @return string The fetched content
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public function fetchUrl(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0) public function fetch(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
{ {
$ret = $this->fetchUrlFull($url, $binary, $timeout, $accept_content, $cookiejar, $redirects); $ret = $this->fetchFull($url, $binary, $timeout, $accept_content, $cookiejar, $redirects);
return $ret->getBody(); return $ret->getBody();
} }
@ -484,7 +484,7 @@ class HTTPRequest
* @return CurlResult With all relevant information, 'body' contains the actual fetched content. * @return CurlResult With all relevant information, 'body' contains the actual fetched content.
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public function fetchUrlFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0) public function fetchFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
{ {
return $this->get( return $this->get(
$url, $url,

View file

@ -1379,7 +1379,7 @@ class Diaspora
Logger::log("Fetch post from ".$source_url, Logger::DEBUG); Logger::log("Fetch post from ".$source_url, Logger::DEBUG);
$envelope = DI::httpRequest()->fetchUrl($source_url); $envelope = DI::httpRequest()->fetch($source_url);
if ($envelope) { if ($envelope) {
Logger::log("Envelope was fetched.", Logger::DEBUG); Logger::log("Envelope was fetched.", Logger::DEBUG);
$x = self::verifyMagicEnvelope($envelope); $x = self::verifyMagicEnvelope($envelope);

View file

@ -102,7 +102,7 @@ class PortableContact
Logger::log('load: ' . $url, Logger::DEBUG); Logger::log('load: ' . $url, Logger::DEBUG);
$fetchresult = DI::httpRequest()->fetchUrlFull($url); $fetchresult = DI::httpRequest()->fetchFull($url);
$s = $fetchresult->getBody(); $s = $fetchresult->getBody();
Logger::log('load: returns ' . $s, Logger::DATA); Logger::log('load: returns ' . $s, Logger::DATA);

View file

@ -184,7 +184,7 @@ class Images
return $data; return $data;
} }
$img_str = DI::httpRequest()->fetchUrl($url, true, 4); $img_str = DI::httpRequest()->fetch($url, true, 4);
if (!$img_str) { if (!$img_str) {
return []; return [];

View file

@ -54,7 +54,7 @@ class CheckVersion
Logger::log("Checking VERSION from: ".$checked_url, Logger::DEBUG); Logger::log("Checking VERSION from: ".$checked_url, Logger::DEBUG);
// fetch the VERSION file // fetch the VERSION file
$gitversion = DBA::escape(trim(DI::httpRequest()->fetchUrl($checked_url))); $gitversion = DBA::escape(trim(DI::httpRequest()->fetch($checked_url)));
Logger::log("Upstream VERSION is: ".$gitversion, Logger::DEBUG); Logger::log("Upstream VERSION is: ".$gitversion, Logger::DEBUG);
DI::config()->set('system', 'git_friendica_version', $gitversion); DI::config()->set('system', 'git_friendica_version', $gitversion);

View file

@ -60,7 +60,7 @@ class CronJobs
// Now trying to register // Now trying to register
$url = 'http://the-federation.info/register/' . DI::baseUrl()->getHostname(); $url = 'http://the-federation.info/register/' . DI::baseUrl()->getHostname();
Logger::debug('Check registering url', ['url' => $url]); Logger::debug('Check registering url', ['url' => $url]);
$ret = DI::httpRequest()->fetchUrl($url); $ret = DI::httpRequest()->fetch($url);
Logger::debug('Check registering answer', ['answer' => $ret]); Logger::debug('Check registering answer', ['answer' => $ret]);
Logger::info('cron_end'); Logger::info('cron_end');
break; break;

View file

@ -53,7 +53,7 @@ class Directory
Logger::log('Updating directory: ' . $arr['url'], Logger::DEBUG); Logger::log('Updating directory: ' . $arr['url'], Logger::DEBUG);
if (strlen($arr['url'])) { if (strlen($arr['url'])) {
DI::httpRequest()->fetchUrl($dir . '?url=' . bin2hex($arr['url'])); DI::httpRequest()->fetch($dir . '?url=' . bin2hex($arr['url']));
} }
return; return;

View file

@ -51,7 +51,7 @@ class SearchDirectory
} }
} }
$x = DI::httpRequest()->fetchUrl(Search::getGlobalDirectory() . '/lsearch?p=1&n=500&search=' . urlencode($search)); $x = DI::httpRequest()->fetch(Search::getGlobalDirectory() . '/lsearch?p=1&n=500&search=' . urlencode($search));
$j = json_decode($x); $j = json_decode($x);
if (!empty($j->results)) { if (!empty($j->results)) {