Revert "HTTPRequest: Replace getInfo() with new parameter 'content_length'"

This reverts commit f3cd973c
This commit is contained in:
Philipp 2020-10-11 23:25:47 +02:00
parent 0449077126
commit 2e8ad098b9
No known key found for this signature in database
GPG key ID: 9A28B7D4FF5667BD
7 changed files with 30 additions and 14 deletions

View file

@ -30,7 +30,6 @@ use Friendica\Util\Network;
use Friendica\Util\Profiler;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\TransferException;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
@ -187,13 +186,6 @@ class HTTPRequest implements IHTTPRequest
$this->logger->notice('Curl redirect.', ['url' => $request->getUri(), 'to' => $uri]);
};
$onHeaders = function (ResponseInterface $response) use ($opts) {
if (!empty($opts['content_length']) &&
$response->getHeaderLine('Content-Length') > $opts['content_length']) {
throw new TransferException('The file is too big!');
}
};
$client = new Client([
'allow_redirect' => [
'max' => 8,
@ -210,9 +202,8 @@ class HTTPRequest implements IHTTPRequest
try {
$response = $client->get($url);
return new GuzzleResponse($response, $url);
} catch (TransferException $exception) {
if ($exception instanceof RequestException &&
$exception->hasResponse()) {
} catch (RequestException $exception) {
if ($exception->hasResponse()) {
return new GuzzleResponse($exception->getResponse(), $url, $exception->getCode(), $exception->getMessage());
} else {
return new CurlResult($url, '', ['http_code' => $exception->getCode()], $exception->getCode(), $exception->getMessage());