mirror of
https://github.com/friendica/friendica
synced 2025-04-28 19:44:23 +02:00
The redundant function "fetchfull" is removed
This commit is contained in:
parent
9bf5b27362
commit
22828388c0
6 changed files with 25 additions and 43 deletions
|
@ -31,22 +31,6 @@ interface ICanSendHttpRequests
|
|||
*/
|
||||
public function fetch(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = '', string $request = ''): string;
|
||||
|
||||
/**
|
||||
* Fetches the whole response of an URL.
|
||||
*
|
||||
* Inner workings and parameters are the same as @ref fetchUrl but returns an array with
|
||||
* all the information collected during the fetch.
|
||||
*
|
||||
* @param string $url URL to fetch
|
||||
* @param string $accept_content supply Accept: header with 'accept_content' as the value
|
||||
* @param int $timeout Timeout in seconds, default system config value or 60 seconds
|
||||
* @param string $cookiejar Path to cookie jar file
|
||||
* @param string $request Request Type
|
||||
*
|
||||
* @return ICanHandleHttpResponses With all relevant information, 'body' contains the actual fetched content.
|
||||
*/
|
||||
public function fetchFull(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = '', string $request = ''): ICanHandleHttpResponses;
|
||||
|
||||
/**
|
||||
* Send a GET to a URL.
|
||||
*
|
||||
|
|
|
@ -271,25 +271,21 @@ class HttpClient implements ICanSendHttpRequests
|
|||
*/
|
||||
public function fetch(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = '', string $request = ''): string
|
||||
{
|
||||
$ret = $this->fetchFull($url, $accept_content, $timeout, $cookiejar, $request);
|
||||
|
||||
return $ret->getBodyString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchFull(string $url, string $accept_content = HttpClientAccept::DEFAULT, int $timeout = 0, string $cookiejar = '', string $request = ''): ICanHandleHttpResponses
|
||||
{
|
||||
return $this->get(
|
||||
$url,
|
||||
$accept_content,
|
||||
[
|
||||
HttpClientOptions::TIMEOUT => $timeout,
|
||||
HttpClientOptions::COOKIEJAR => $cookiejar,
|
||||
HttpClientOptions::REQUEST => $request,
|
||||
]
|
||||
);
|
||||
try {
|
||||
$ret = $this->get(
|
||||
$url,
|
||||
$accept_content,
|
||||
[
|
||||
HttpClientOptions::TIMEOUT => $timeout,
|
||||
HttpClientOptions::COOKIEJAR => $cookiejar,
|
||||
HttpClientOptions::REQUEST => $request,
|
||||
]
|
||||
);
|
||||
return $ret->getBodyString();
|
||||
} catch (\Throwable $th) {
|
||||
$this->logger->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
private function getUserAgent(string $type = ''): string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue