mirror of
https://github.com/friendica/friendica
synced 2025-04-27 15:10:11 +00:00
Move post/curl/fetchUrl/fetchUrlFull to own class "Network\HTTPRequest"
This commit is contained in:
parent
2889d59b83
commit
5344efef71
43 changed files with 528 additions and 485 deletions
|
@ -21,12 +21,12 @@
|
|||
|
||||
namespace Friendica\Protocol;
|
||||
|
||||
use Friendica\Util\JsonLD;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Model\APContact;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPRequest;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
use Friendica\Util\JsonLD;
|
||||
|
||||
/**
|
||||
* ActivityPub Protocol class
|
||||
|
@ -93,7 +93,7 @@ class ActivityPub
|
|||
return HTTPSignature::fetch($url, $uid);
|
||||
}
|
||||
|
||||
$curlResult = Network::curl($url, false, ['accept_content' => 'application/activity+json, application/ld+json']);
|
||||
$curlResult = HTTPRequest::curl($url, false, ['accept_content' => 'application/activity+json, application/ld+json']);
|
||||
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ use Friendica\Model\Post\Category;
|
|||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPRequest;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -1194,7 +1195,7 @@ class DFRN
|
|||
|
||||
Logger::log('dfrn_deliver: ' . $url);
|
||||
|
||||
$curlResult = Network::curl($url);
|
||||
$curlResult = HTTPRequest::curl($url);
|
||||
|
||||
if ($curlResult->isTimeout()) {
|
||||
return -2; // timed out
|
||||
|
@ -1343,7 +1344,7 @@ class DFRN
|
|||
|
||||
Logger::debug('dfrn_deliver', ['post' => $postvars]);
|
||||
|
||||
$postResult = Network::post($contact['notify'], $postvars);
|
||||
$postResult = HTTPRequest::post($contact['notify'], $postvars);
|
||||
|
||||
$xml = $postResult->getBody();
|
||||
|
||||
|
@ -1440,7 +1441,7 @@ class DFRN
|
|||
|
||||
$content_type = ($public_batch ? "application/magic-envelope+xml" : "application/json");
|
||||
|
||||
$postResult = Network::post($dest_url, $envelope, ["Content-Type: ".$content_type]);
|
||||
$postResult = HTTPRequest::post($dest_url, $envelope, ["Content-Type: " . $content_type]);
|
||||
$xml = $postResult->getBody();
|
||||
|
||||
$curl_stat = $postResult->getReturnCode();
|
||||
|
|
|
@ -41,6 +41,7 @@ use Friendica\Model\Mail;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPRequest;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -1379,7 +1380,7 @@ class Diaspora
|
|||
|
||||
Logger::log("Fetch post from ".$source_url, Logger::DEBUG);
|
||||
|
||||
$envelope = Network::fetchUrl($source_url);
|
||||
$envelope = HTTPRequest::fetchUrl($source_url);
|
||||
if ($envelope) {
|
||||
Logger::log("Envelope was fetched.", Logger::DEBUG);
|
||||
$x = self::verifyMagicEnvelope($envelope);
|
||||
|
@ -3260,7 +3261,7 @@ class Diaspora
|
|||
if (!intval(DI::config()->get("system", "diaspora_test"))) {
|
||||
$content_type = (($public_batch) ? "application/magic-envelope+xml" : "application/json");
|
||||
|
||||
$postResult = Network::post($dest_url."/", $envelope, ["Content-Type: ".$content_type]);
|
||||
$postResult = HTTPRequest::post($dest_url . "/", $envelope, ["Content-Type: " . $content_type]);
|
||||
$return_code = $postResult->getReturnCode();
|
||||
} else {
|
||||
Logger::log("test_mode");
|
||||
|
|
|
@ -39,10 +39,10 @@ use Friendica\Model\Item;
|
|||
use Friendica\Model\ItemURI;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPRequest;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
|
@ -756,7 +756,7 @@ class OStatus
|
|||
|
||||
self::$conv_list[$conversation] = true;
|
||||
|
||||
$curlResult = Network::curl($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
|
||||
$curlResult = HTTPRequest::curl($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
|
||||
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return;
|
||||
|
@ -785,7 +785,7 @@ class OStatus
|
|||
}
|
||||
}
|
||||
if ($file != '') {
|
||||
$conversation_atom = Network::curl($attribute['href']);
|
||||
$conversation_atom = HTTPRequest::curl($attribute['href']);
|
||||
|
||||
if ($conversation_atom->isSuccess()) {
|
||||
$xml = $conversation_atom->getBody();
|
||||
|
@ -902,7 +902,7 @@ class OStatus
|
|||
return;
|
||||
}
|
||||
|
||||
$curlResult = Network::curl($self);
|
||||
$curlResult = HTTPRequest::curl($self);
|
||||
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return;
|
||||
|
@ -949,7 +949,7 @@ class OStatus
|
|||
}
|
||||
|
||||
$stored = false;
|
||||
$curlResult = Network::curl($related, false, ['accept_content' => 'application/atom+xml, text/html']);
|
||||
$curlResult = HTTPRequest::curl($related, false, ['accept_content' => 'application/atom+xml, text/html']);
|
||||
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return;
|
||||
|
@ -980,7 +980,7 @@ class OStatus
|
|||
}
|
||||
}
|
||||
if ($atom_file != '') {
|
||||
$curlResult = Network::curl($atom_file);
|
||||
$curlResult = HTTPRequest::curl($atom_file);
|
||||
|
||||
if ($curlResult->isSuccess()) {
|
||||
Logger::log('Fetched XML for URI ' . $related_uri, Logger::DEBUG);
|
||||
|
@ -992,7 +992,7 @@ class OStatus
|
|||
|
||||
// Workaround for older GNU Social servers
|
||||
if (($xml == '') && strstr($related, '/notice/')) {
|
||||
$curlResult = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related).'.atom');
|
||||
$curlResult = HTTPRequest::curl(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom');
|
||||
|
||||
if ($curlResult->isSuccess()) {
|
||||
Logger::log('GNU Social workaround to fetch XML for URI ' . $related_uri, Logger::DEBUG);
|
||||
|
@ -1003,7 +1003,7 @@ class OStatus
|
|||
// Even more worse workaround for GNU Social ;-)
|
||||
if ($xml == '') {
|
||||
$related_guess = self::convertHref($related_uri);
|
||||
$curlResult = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom');
|
||||
$curlResult = HTTPRequest::curl(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom');
|
||||
|
||||
if ($curlResult->isSuccess()) {
|
||||
Logger::log('GNU Social workaround 2 to fetch XML for URI ' . $related_uri, Logger::DEBUG);
|
||||
|
|
|
@ -30,8 +30,8 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\GServer;
|
||||
use Friendica\Network\HTTPRequest;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
/**
|
||||
|
@ -103,7 +103,7 @@ class PortableContact
|
|||
|
||||
Logger::log('load: ' . $url, Logger::DEBUG);
|
||||
|
||||
$fetchresult = Network::fetchUrlFull($url);
|
||||
$fetchresult = HTTPRequest::fetchUrlFull($url);
|
||||
$s = $fetchresult->getBody();
|
||||
|
||||
Logger::log('load: returns ' . $s, Logger::DATA);
|
||||
|
@ -251,7 +251,7 @@ class PortableContact
|
|||
*/
|
||||
private static function fetchServerlist($poco)
|
||||
{
|
||||
$curlResult = Network::curl($poco . "/@server");
|
||||
$curlResult = HTTPRequest::curl($poco . "/@server");
|
||||
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return;
|
||||
|
@ -291,7 +291,7 @@ class PortableContact
|
|||
|
||||
Logger::info("Fetch all users from the server " . $server["url"]);
|
||||
|
||||
$curlResult = Network::curl($url);
|
||||
$curlResult = HTTPRequest::curl($url);
|
||||
|
||||
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
|
||||
$data = json_decode($curlResult->getBody(), true);
|
||||
|
@ -314,7 +314,7 @@ class PortableContact
|
|||
|
||||
$success = false;
|
||||
|
||||
$curlResult = Network::curl($url);
|
||||
$curlResult = HTTPRequest::curl($url);
|
||||
|
||||
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
|
||||
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
|
||||
$url = $server['poco'] . '/' . $username . '/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,contactType,generation';
|
||||
|
||||
$curlResult = Network::curl($url);
|
||||
$curlResult = HTTPRequest::curl($url);
|
||||
|
||||
if ($curlResult->isSuccess()) {
|
||||
$data = json_decode($curlResult->getBody(), true);
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
namespace Friendica\Protocol;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Network\HTTPRequest;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
@ -72,7 +72,7 @@ class Salmon
|
|||
$ret[$x] = substr($ret[$x], 5);
|
||||
}
|
||||
} elseif (Strings::normaliseLink($ret[$x]) == 'http://') {
|
||||
$ret[$x] = Network::fetchUrl($ret[$x]);
|
||||
$ret[$x] = HTTPRequest::fetchUrl($ret[$x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ class Salmon
|
|||
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
|
||||
|
||||
// slap them
|
||||
$postResult = Network::post($url, $salmon, [
|
||||
$postResult = HTTPRequest::post($url, $salmon, [
|
||||
'Content-type: application/magic-envelope+xml',
|
||||
'Content-length: ' . strlen($salmon)
|
||||
]);
|
||||
|
@ -180,7 +180,7 @@ class Salmon
|
|||
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
|
||||
|
||||
// slap them
|
||||
$postResult = Network::post($url, $salmon, [
|
||||
$postResult = HTTPRequest::post($url, $salmon, [
|
||||
'Content-type: application/magic-envelope+xml',
|
||||
'Content-length: ' . strlen($salmon)
|
||||
]);
|
||||
|
@ -203,7 +203,7 @@ class Salmon
|
|||
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
|
||||
|
||||
// slap them
|
||||
$postResult = Network::post($url, $salmon, [
|
||||
$postResult = HTTPRequest::post($url, $salmon, [
|
||||
'Content-type: application/magic-envelope+xml',
|
||||
'Content-length: ' . strlen($salmon)]);
|
||||
$return_code = $postResult->getReturnCode();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue