mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
Remove $binary flag for HTTPRequest::get(), HTTPRequest::fetch(), HTTPRequest::fetchAll() (deprecated since PHP 5.1.3)
This commit is contained in:
parent
b3e5621d37
commit
a6fc9cd32e
16 changed files with 31 additions and 40 deletions
|
@ -59,7 +59,7 @@ class HTTPRequest implements IHTTPRequest
|
|||
*
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function get(string $url, bool $binary = false, array $opts = [], int &$redirects = 0)
|
||||
public function get(string $url, array $opts = [], int &$redirects = 0)
|
||||
{
|
||||
$stamp1 = microtime(true);
|
||||
|
||||
|
@ -172,12 +172,7 @@ class HTTPRequest implements IHTTPRequest
|
|||
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||
}
|
||||
|
||||
if ($binary) {
|
||||
@curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
|
||||
}
|
||||
|
||||
// don't let curl abort the entire application
|
||||
// if it throws any errors.
|
||||
$logger = $this->logger;
|
||||
|
||||
$s = @curl_exec($ch);
|
||||
$curl_info = @curl_getinfo($ch);
|
||||
|
@ -196,7 +191,7 @@ class HTTPRequest implements IHTTPRequest
|
|||
$redirects++;
|
||||
$this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
|
||||
@curl_close($ch);
|
||||
return $this->get($curlResponse->getRedirectUrl(), $binary, $opts, $redirects);
|
||||
return $this->get($curlResponse->getRedirectUrl(), $opts, $redirects);
|
||||
}
|
||||
|
||||
@curl_close($ch);
|
||||
|
@ -435,9 +430,9 @@ class HTTPRequest implements IHTTPRequest
|
|||
*
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function fetch(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
|
||||
public function fetch(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
|
||||
{
|
||||
$ret = $this->fetchFull($url, $binary, $timeout, $accept_content, $cookiejar, $redirects);
|
||||
$ret = $this->fetchFull($url, $timeout, $accept_content, $cookiejar, $redirects);
|
||||
|
||||
return $ret->getBody();
|
||||
}
|
||||
|
@ -449,11 +444,10 @@ class HTTPRequest implements IHTTPRequest
|
|||
*
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function fetchFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
|
||||
public function fetchFull(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
|
||||
{
|
||||
return $this->get(
|
||||
$url,
|
||||
$binary,
|
||||
[
|
||||
'timeout' => $timeout,
|
||||
'accept_content' => $accept_content,
|
||||
|
|
|
@ -34,7 +34,6 @@ interface IHTTPRequest
|
|||
* to preserve cookies from one request to the next.
|
||||
*
|
||||
* @param string $url URL to fetch
|
||||
* @param bool $binary default false
|
||||
* TRUE if asked to return binary results (file download)
|
||||
* @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
|
||||
|
@ -42,7 +41,7 @@ interface IHTTPRequest
|
|||
*
|
||||
* @return string The fetched content
|
||||
*/
|
||||
public function fetch(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
|
||||
public function fetch(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
|
||||
|
||||
/**
|
||||
* Fetches the whole response of an URL.
|
||||
|
@ -51,7 +50,6 @@ interface IHTTPRequest
|
|||
* all the information collected during the fetch.
|
||||
*
|
||||
* @param string $url URL to fetch
|
||||
* @param bool $binary default false
|
||||
* TRUE if asked to return binary results (file download)
|
||||
* @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
|
||||
|
@ -59,13 +57,12 @@ interface IHTTPRequest
|
|||
*
|
||||
* @return CurlResult With all relevant information, 'body' contains the actual fetched content.
|
||||
*/
|
||||
public function fetchFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
|
||||
public function fetchFull(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
|
||||
|
||||
/**
|
||||
* Send a GET to an URL.
|
||||
*
|
||||
* @param string $url URL to fetch
|
||||
* @param bool $binary default false
|
||||
* TRUE if asked to return binary results (file download)
|
||||
* @param array $opts (optional parameters) assoziative array with:
|
||||
* 'accept_content' => supply Accept: header with 'accept_content' as the value
|
||||
|
@ -78,7 +75,7 @@ interface IHTTPRequest
|
|||
*
|
||||
* @return CurlResult
|
||||
*/
|
||||
public function get(string $url, bool $binary = false, array $opts = []);
|
||||
public function get(string $url, array $opts = []);
|
||||
|
||||
/**
|
||||
* Send POST request to an URL
|
||||
|
|
|
@ -169,7 +169,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, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
||||
$curlResult = DI::httpRequest()->get($ssl_url, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
||||
$ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$xml = $curlResult->getBody();
|
||||
|
@ -186,7 +186,7 @@ class Probe
|
|||
}
|
||||
|
||||
if (!is_object($xrd) && !empty($url)) {
|
||||
$curlResult = DI::httpRequest()->get($url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
||||
$curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
|
||||
$connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
|
||||
if ($curlResult->isTimeout()) {
|
||||
Logger::info('Probing timeout', ['url' => $url]);
|
||||
|
@ -941,7 +941,7 @@ class Probe
|
|||
{
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20);
|
||||
|
||||
$curlResult = DI::httpRequest()->get($url, false, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
|
||||
$curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
|
||||
if ($curlResult->isTimeout()) {
|
||||
self::$istimeout = true;
|
||||
return [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue