Use HTTPRequestOptions constants for HTTPClient::get()
This commit is contained in:
parent
aad7bac686
commit
0cafa871f1
|
@ -24,6 +24,7 @@ namespace Friendica\Core;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\HTTPRequestOptions;
|
||||
use Friendica\Object\Search\ContactResult;
|
||||
use Friendica\Object\Search\ResultList;
|
||||
use Friendica\Util\Network;
|
||||
|
@ -227,7 +228,7 @@ class Search
|
|||
$return = Contact::searchByName($search, $mode);
|
||||
} else {
|
||||
$p = $page > 1 ? 'p=' . $page : '';
|
||||
$curlResult = DI::httpRequest()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), ['accept_content' => ['application/json']]);
|
||||
$curlResult = DI::httpRequest()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), [HTTPRequestOptions::ACCEPT_CONTENT => ['application/json']]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$searchResult = json_decode($curlResult->getBody(), true);
|
||||
if (!empty($searchResult['profiles'])) {
|
||||
|
|
|
@ -32,6 +32,7 @@ use Friendica\Database\Database;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Register;
|
||||
use Friendica\Network\HTTPRequestOptions;
|
||||
use Friendica\Network\IHTTPResult;
|
||||
use Friendica\Protocol\Relay;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -314,7 +315,7 @@ class GServer
|
|||
|
||||
// When a nodeinfo is present, we don't need to dig further
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
$curlResult = DI::httpRequest()->get($url . '/.well-known/nodeinfo', ['timeout' => $xrd_timeout]);
|
||||
$curlResult = DI::httpRequest()->get($url . '/.well-known/nodeinfo', [HTTPRequestOptions::TIMEOUT => $xrd_timeout]);
|
||||
if ($curlResult->isTimeout()) {
|
||||
self::setFailure($url);
|
||||
return false;
|
||||
|
@ -322,7 +323,7 @@ class GServer
|
|||
|
||||
// On a redirect follow the new host but mark the old one as failure
|
||||
if ($curlResult->isSuccess() && (parse_url($url, PHP_URL_HOST) != parse_url($curlResult->getRedirectUrl(), PHP_URL_HOST))) {
|
||||
$curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout]);
|
||||
$curlResult = DI::httpRequest()->get($url, [HTTPRequestOptions::TIMEOUT => $xrd_timeout]);
|
||||
if (parse_url($url, PHP_URL_HOST) != parse_url($curlResult->getRedirectUrl(), PHP_URL_HOST)) {
|
||||
Logger::info('Found redirect. Mark old entry as failure', ['old' => $url, 'new' => $curlResult->getRedirectUrl()]);
|
||||
self::setFailure($url);
|
||||
|
@ -358,7 +359,7 @@ class GServer
|
|||
$basedata = ['detection-method' => self::DETECT_MANUAL];
|
||||
}
|
||||
|
||||
$curlResult = DI::httpRequest()->get($baseurl, ['timeout' => $xrd_timeout]);
|
||||
$curlResult = DI::httpRequest()->get($baseurl, [HTTPRequestOptions::TIMEOUT => $xrd_timeout]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
if ((parse_url($baseurl, PHP_URL_HOST) != parse_url($curlResult->getRedirectUrl(), PHP_URL_HOST))) {
|
||||
Logger::info('Found redirect. Mark old entry as failure', ['old' => $url, 'new' => $curlResult->getRedirectUrl()]);
|
||||
|
@ -382,7 +383,7 @@ class GServer
|
|||
// When the base path doesn't seem to contain a social network we try the complete path.
|
||||
// Most detectable system have to be installed in the root directory.
|
||||
// We checked the base to avoid false positives.
|
||||
$curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout]);
|
||||
$curlResult = DI::httpRequest()->get($url, [HTTPRequestOptions::TIMEOUT => $xrd_timeout]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$urldata = self::analyseRootHeader($curlResult, $serverdata);
|
||||
$urldata = self::analyseRootBody($curlResult, $urldata, $url);
|
||||
|
@ -958,7 +959,7 @@ class GServer
|
|||
private static function validHostMeta(string $url)
|
||||
{
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
$curlResult = DI::httpRequest()->get($url . '/.well-known/host-meta', ['timeout' => $xrd_timeout]);
|
||||
$curlResult = DI::httpRequest()->get($url . '/.well-known/host-meta', [HTTPRequestOptions::TIMEOUT => $xrd_timeout]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1728,7 +1729,7 @@ class GServer
|
|||
|
||||
if (!empty($accesstoken)) {
|
||||
$api = 'https://instances.social/api/1.0/instances/list?count=0';
|
||||
$curlResult = DI::httpRequest()->get($api, ['header' => ['Authorization' => ['Bearer ' . $accesstoken]]]);
|
||||
$curlResult = DI::httpRequest()->get($api, [HTTPRequestOptions::HEADERS => ['Authorization' => ['Bearer ' . $accesstoken]]]);
|
||||
|
||||
if ($curlResult->isSuccess()) {
|
||||
$servers = json_decode($curlResult->getBody(), true);
|
||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPRequestOptions;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
|
@ -101,7 +102,7 @@ class Magic extends BaseModule
|
|||
);
|
||||
|
||||
// Try to get an authentication token from the other instance.
|
||||
$curlResult = DI::httpRequest()->get($basepath . '/owa', ['header' => $header]);
|
||||
$curlResult = DI::httpRequest()->get($basepath . '/owa', [HTTPRequestOptions::HEADERS => $header]);
|
||||
|
||||
if ($curlResult->isSuccess()) {
|
||||
$j = json_decode($curlResult->getBody(), true);
|
||||
|
|
|
@ -170,7 +170,7 @@ class Probe
|
|||
Logger::info('Probing', ['host' => $host, 'ssl_url' => $ssl_url, 'url' => $url, 'callstack' => System::callstack(20)]);
|
||||
$xrd = null;
|
||||
|
||||
$curlResult = DI::httpRequest()->get($ssl_url, ['timeout' => $xrd_timeout, 'accept_content' => ['application/xrd+xml']]);
|
||||
$curlResult = DI::httpRequest()->get($ssl_url, [HTTPRequestOptions::TIMEOUT => $xrd_timeout, HTTPRequestOptions::ACCEPT_CONTENT => ['application/xrd+xml']]);
|
||||
$ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$xml = $curlResult->getBody();
|
||||
|
@ -187,7 +187,7 @@ class Probe
|
|||
}
|
||||
|
||||
if (!is_object($xrd) && !empty($url)) {
|
||||
$curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout, 'accept_content' => ['application/xrd+xml']]);
|
||||
$curlResult = DI::httpRequest()->get($url, [HTTPRequestOptions::TIMEOUT => $xrd_timeout, HTTPRequestOptions::ACCEPT_CONTENT => ['application/xrd+xml']]);
|
||||
$connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
|
||||
if ($curlResult->isTimeout()) {
|
||||
Logger::info('Probing timeout', ['url' => $url]);
|
||||
|
@ -424,7 +424,7 @@ class Probe
|
|||
*/
|
||||
private static function getHideStatus($url)
|
||||
{
|
||||
$curlResult = DI::httpRequest()->get($url, ['content_length' => 1000000]);
|
||||
$curlResult = DI::httpRequest()->get($url, [HTTPRequestOptions::CONTENT_LENGTH => 1000000]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -940,7 +940,7 @@ class Probe
|
|||
{
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20);
|
||||
|
||||
$curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout, 'accept_content' => [$type]]);
|
||||
$curlResult = DI::httpRequest()->get($url, [HTTPRequestOptions::TIMEOUT => $xrd_timeout, HTTPRequestOptions::ACCEPT_CONTENT => [$type]]);
|
||||
if ($curlResult->isTimeout()) {
|
||||
self::$istimeout = true;
|
||||
return [];
|
||||
|
|
|
@ -38,6 +38,7 @@ use Friendica\Model\ItemURI;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPRequestOptions;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Images;
|
||||
|
@ -727,7 +728,7 @@ class OStatus
|
|||
|
||||
self::$conv_list[$conversation] = true;
|
||||
|
||||
$curlResult = DI::httpRequest()->get($conversation, ['accept_content' => ['application/atom+xml', 'text/html']]);
|
||||
$curlResult = DI::httpRequest()->get($conversation, [HTTPRequestOptions::ACCEPT_CONTENT => ['application/atom+xml', 'text/html']]);
|
||||
|
||||
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
|
||||
return;
|
||||
|
@ -921,7 +922,7 @@ class OStatus
|
|||
}
|
||||
|
||||
$stored = false;
|
||||
$curlResult = DI::httpRequest()->get($related, ['accept_content' => ['application/atom+xml', 'text/html']]);
|
||||
$curlResult = DI::httpRequest()->get($related, [HTTPRequestOptions::ACCEPT_CONTENT => ['application/atom+xml', 'text/html']]);
|
||||
|
||||
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
|
||||
return;
|
||||
|
|
|
@ -30,6 +30,7 @@ use Friendica\Database\Database;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\HTTPRequestOptions;
|
||||
|
||||
/**
|
||||
* Get information about a given URL
|
||||
|
@ -213,7 +214,7 @@ class ParseUrl
|
|||
return $siteinfo;
|
||||
}
|
||||
|
||||
$curlResult = DI::httpRequest()->get($url, ['content_length' => 1000000]);
|
||||
$curlResult = DI::httpRequest()->get($url, [HTTPRequestOptions::CONTENT_LENGTH => 1000000]);
|
||||
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
|
||||
return $siteinfo;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ use Friendica\Model\Contact;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPRequestOptions;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Protocol\Email;
|
||||
|
@ -152,7 +153,7 @@ class OnePoll
|
|||
}
|
||||
|
||||
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
|
||||
$curlResult = DI::httpRequest()->get($contact['poll'], ['cookiejar' => $cookiejar]);
|
||||
$curlResult = DI::httpRequest()->get($contact['poll'], [HTTPRequestOptions::COOKIEJAR => $cookiejar]);
|
||||
unlink($cookiejar);
|
||||
|
||||
if ($curlResult->isTimeout()) {
|
||||
|
|
Loading…
Reference in a new issue