Curl Response Refactoring
- extended Curl to parse Curl Response - refactored Network::curl() - replaced every Network::curl() execution with the new Curl container
This commit is contained in:
parent
904fee3bed
commit
2dec8895a9
20 changed files with 466 additions and 382 deletions
|
@ -2567,6 +2567,5 @@ function admin_page_features(App $a)
|
|||
function admin_page_server_vital()
|
||||
{
|
||||
// Fetch the host-meta to check if this really is a vital server
|
||||
$serverret = Network::curl(System::baseUrl() . '/.well-known/host-meta');
|
||||
return $serverret["success"];
|
||||
return Network::curl(System::baseUrl() . '/.well-known/host-meta')->isSuccess();
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ function feedtest_content(App $a)
|
|||
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
|
||||
|
||||
$ret = Network::curl($contact['poll']);
|
||||
$xml = $ret['body'];
|
||||
$xml = Network::fetchUrl($contact['poll']);
|
||||
|
||||
$dummy = null;
|
||||
$import_result = Feed::import($xml, $importer, $contact, $dummy, true);
|
||||
|
|
|
@ -44,14 +44,14 @@ function ostatus_subscribe_content(App $a) {
|
|||
$api = $contact["baseurl"]."/api/";
|
||||
|
||||
// Fetching friends
|
||||
$data = Network::curl($api."statuses/friends.json?screen_name=".$contact["nick"]);
|
||||
$curlResult = Network::curl($api."statuses/friends.json?screen_name=".$contact["nick"]);
|
||||
|
||||
if (!$data["success"]) {
|
||||
if (!$curlResult->isSuccess()) {
|
||||
PConfig::delete($uid, "ostatus", "legacy_contact");
|
||||
return $o.L10n::t("Couldn't fetch friends for contact.");
|
||||
}
|
||||
|
||||
PConfig::set($uid, "ostatus", "legacy_friends", $data["body"]);
|
||||
PConfig::set($uid, "ostatus", "legacy_friends", $curlResult->getBody());
|
||||
}
|
||||
|
||||
$friends = json_decode(PConfig::get($uid, "ostatus", "legacy_friends"));
|
||||
|
@ -72,8 +72,8 @@ function ostatus_subscribe_content(App $a) {
|
|||
|
||||
$o .= "<p>".$counter."/".$total.": ".$url;
|
||||
|
||||
$data = Probe::uri($url);
|
||||
if ($data["network"] == Protocol::OSTATUS) {
|
||||
$curlResult = Probe::uri($url);
|
||||
if ($curlResult["network"] == Protocol::OSTATUS) {
|
||||
$result = Contact::createFromProbe($uid, $url, true, Protocol::OSTATUS);
|
||||
if ($result["success"]) {
|
||||
$o .= " - ".L10n::t("success");
|
||||
|
|
|
@ -60,12 +60,12 @@ function parse_url_content(App $a)
|
|||
// the URL with the corresponding BBCode media tag
|
||||
$redirects = 0;
|
||||
// Fetch the header of the URL
|
||||
$result = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]);
|
||||
$curlResponse = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]);
|
||||
|
||||
if ($result['success']) {
|
||||
if ($curlResponse->isSuccess()) {
|
||||
// Convert the header fields into an array
|
||||
$hdrs = [];
|
||||
$h = explode("\n", $result['header']);
|
||||
$h = explode("\n", $curlResponse->getHeader());
|
||||
foreach ($h as $l) {
|
||||
$header = array_map('trim', explode(':', trim($l), 2));
|
||||
if (count($header) == 2) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue