*
*/
- $res = Network::post($dfrn_confirm, $params, null, $redirects, 120)->getBody();
+ $res = Network::post($dfrn_confirm, $params, null, 120)->getBody();
Logger::log(' Confirm: received data: ' . $res, Logger::DATA);
// Check if the URL is an image, video or audio file. If so format
// the URL with the corresponding BBCode media tag
- $redirects = 0;
// Fetch the header of the URL
- $curlResponse = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]);
+ $curlResponse = Network::curl($url, false, ['novalidate' => true, 'nobody' => true]);
if ($curlResponse->isSuccess()) {
// Convert the header fields into an array
if (!in_array($ext, $noexts)) {
// try oembed autodiscovery
- $redirects = 0;
- $html_text = Network::fetchUrl($embedurl, false, $redirects, 15, 'text/*');
+ $html_text = Network::fetchUrl($embedurl, false, 15, 'text/*');
if ($html_text) {
$dom = @DOMDocument::loadHTML($html_text);
if ($dom) {
$searchUrl .= '&page=' . $page;
}
- $red = 0;
- $resultJson = Network::fetchUrl($searchUrl, false, $red, 0, 'application/json');
+ $resultJson = Network::fetchUrl($searchUrl, false, 0, 'application/json');
$results = json_decode($resultJson, true);
}
$url = System::baseUrl()."/worker";
- Network::fetchUrl($url, false, $redirects, 1);
+ Network::fetchUrl($url, false, 1);
}
/**
$webfinger = 'https://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr);
- $curlResult = Network::curl($webfinger, false, $redirects, ['accept_content' => 'application/jrd+json,application/json']);
+ $curlResult = Network::curl($webfinger, false, ['accept_content' => 'application/jrd+json,application/json']);
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
return false;
}
);
// Try to get an authentication token from the other instance.
- $curlResult = Network::curl($basepath . '/owa', false, $redirects, ['headers' => $headers]);
+ $curlResult = Network::curl($basepath . '/owa', false, ['headers' => $headers]);
if ($curlResult->isSuccess()) {
$j = json_decode($curlResult->getBody(), true);
$url = "http://".$host."/.well-known/host-meta";
$xrd_timeout = Config::get('system', 'xrd_timeout', 20);
- $redirects = 0;
Logger::log("Probing for ".$host, Logger::DEBUG);
$xrd = null;
- $curlResult = Network::curl($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
+ $curlResult = Network::curl($ssl_url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
if ($curlResult->isSuccess()) {
$xml = $curlResult->getBody();
$xrd = XML::parseString($xml, false);
}
if (!is_object($xrd)) {
- $curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
+ $curlResult = Network::curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
if ($curlResult->isTimeout()) {
Logger::log("Probing timeout for " . $url, Logger::DEBUG);
self::$istimeout = true;
private static function webfinger($url, $type)
{
$xrd_timeout = Config::get('system', 'xrd_timeout', 20);
- $redirects = 0;
- $curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
+ $curlResult = Network::curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
return false;
$data = Cache::get($url);
if (is_null($data) || !$data || !is_array($data)) {
- $img_str = Network::fetchUrl($url, true, $redirects, 4);
+ $img_str = Network::fetchUrl($url, true, 4);
if (!$img_str) {
return false;
return HTTPSignature::fetch($url, $uid);
}
- $curlResult = Network::curl($url, false, $redirects, ['accept_content' => 'application/activity+json, application/ld+json']);
+ $curlResult = Network::curl($url, false, ['accept_content' => 'application/activity+json, application/ld+json']);
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
return false;
}
self::$conv_list[$conversation] = true;
- $curlResult = Network::curl($conversation, false, $redirects, ['accept_content' => 'application/atom+xml, text/html']);
+ $curlResult = Network::curl($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
if (!$curlResult->isSuccess()) {
return;
}
$stored = false;
- $curlResult = Network::curl($related, false, $redirects, ['accept_content' => 'application/atom+xml, text/html']);
+ $curlResult = Network::curl($related, false, ['accept_content' => 'application/atom+xml, text/html']);
if (!$curlResult->isSuccess()) {
return;
$server_url = str_replace("http://", "https://", $server_url);
// We set the timeout to 20 seconds since this operation should be done in no time if the server was vital
- $curlResult = Network::curl($server_url."/.well-known/host-meta", false, $redirects, ['timeout' => 20]);
+ $curlResult = Network::curl($server_url."/.well-known/host-meta", false, ['timeout' => 20]);
// Quit if there is a timeout.
// But we want to make sure to only quit if we are mostly sure that this server url fits.
$server_url = str_replace("https://", "http://", $server_url);
// We set the timeout to 20 seconds since this operation should be done in no time if the server was vital
- $curlResult = Network::curl($server_url."/.well-known/host-meta", false, $redirects, ['timeout' => 20]);
+ $curlResult = Network::curl($server_url."/.well-known/host-meta", false, ['timeout' => 20]);
// Quit if there is a timeout
if ($curlResult->isTimeout()) {
if (!empty($accesstoken)) {
$api = 'https://instances.social/api/1.0/instances/list?count=0';
$header = ['Authorization: Bearer '.$accesstoken];
- $curlResult = Network::curl($api, false, $redirects, ['headers' => $header]);
+ $curlResult = Network::curl($api, false, ['headers' => $header]);
if ($curlResult->isSuccess()) {
$servers = json_decode($curlResult->getBody(), true);
$curl_opts = $opts;
$curl_opts['header'] = $headers;
- $curlResult = Network::curl($request, false, $redirects, $curl_opts);
+ $curlResult = Network::curl($request, false, $curl_opts);
$return_code = $curlResult->getReturnCode();
Logger::log('Fetched for user ' . $uid . ' from ' . $request . ' returned ' . $return_code, Logger::DEBUG);
* @param string $url URL to fetch
* @param bool $binary default false
* TRUE if asked to return binary results (file download)
- * @param int $redirects The recursion counter for internal use - default 0
* @param int $timeout Timeout in seconds, default system config value or 60 seconds
* @param string $accept_content supply Accept: header with 'accept_content' as the value
* @param string $cookiejar Path to cookie jar file
+ * @param int $redirects The recursion counter for internal use - default 0
*
* @return string The fetched content
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function fetchUrl(string $url, bool $binary = false, int &$redirects = 0, int $timeout = 0, string $accept_content = null, string $cookiejar = '')
+ public static function fetchUrl(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
{
- $ret = self::fetchUrlFull($url, $binary, $redirects, $timeout, $accept_content, $cookiejar);
+ $ret = self::fetchUrlFull($url, $binary, $timeout, $accept_content, $cookiejar, $redirects);
return $ret->getBody();
}
* @param string $url URL to fetch
* @param bool $binary default false
* TRUE if asked to return binary results (file download)
- * @param int $redirects The recursion counter for internal use - default 0
* @param int $timeout Timeout in seconds, default system config value or 60 seconds
* @param string $accept_content supply Accept: header with 'accept_content' as the value
* @param string $cookiejar Path to cookie jar file
+ * @param int $redirects The recursion counter for internal use - default 0
*
* @return CurlResult With all relevant information, 'body' contains the actual fetched content.
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function fetchUrlFull(string $url, bool $binary = false, int &$redirects = 0, int $timeout = 0, string $accept_content = null, string $cookiejar = '')
+ public static function fetchUrlFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
{
return self::curl(
$url,
$binary,
- $redirects,
- ['timeout'=>$timeout,
- 'accept_content'=>$accept_content,
- 'cookiejar'=>$cookiejar
- ]
+ [
+ 'timeout' => $timeout,
+ 'accept_content' => $accept_content,
+ 'cookiejar' => $cookiejar
+ ],
+ $redirects
);
}
* @param string $url URL to fetch
* @param bool $binary default false
* TRUE if asked to return binary results (file download)
- * @param int $redirects The recursion counter for internal use - default 0
* @param array $opts (optional parameters) assoziative array with:
* 'accept_content' => supply Accept: header with 'accept_content' as the value
* 'timeout' => int Timeout in seconds, default system config value or 60 seconds
* 'nobody' => only return the header
* 'cookiejar' => path to cookie jar file
* 'header' => header array
+ * @param int $redirects The recursion counter for internal use - default 0
*
* @return CurlResult
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function curl(string $url, bool $binary = false, int &$redirects = 0, array $opts = [])
+ public static function curl(string $url, bool $binary = false, array $opts = [], int &$redirects = 0)
{
$stamp1 = microtime(true);
$redirects++;
Logger::log('curl: redirect ' . $url . ' to ' . $curlResponse->getRedirectUrl());
@curl_close($ch);
- return self::curl($curlResponse->getRedirectUrl(), $binary, $redirects, $opts);
+ return self::curl($curlResponse->getRedirectUrl(), $binary, $opts, $redirects);
}
@curl_close($ch);
* @return CurlResult The content
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function post(string $url, $params, string $headers = null, int &$redirects = 0, int $timeout = 0)
+ public static function post(string $url, $params, string $headers = null, int $timeout = 0, int &$redirects = 0)
{
$stamp1 = microtime(true);
}
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
- $curlResult = Network::curl($contact['poll'], false, $redirects, ['cookiejar' => $cookiejar]);
+ $curlResult = Network::curl($contact['poll'], false, ['cookiejar' => $cookiejar]);
unlink($cookiejar);
if ($curlResult->isTimeout()) {