From 908d2594ed7cda13f2d46d62c8f23d2b8aa8b817 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 29 Mar 2022 08:57:38 +0000 Subject: [PATCH] Use "HttpClientOptions" --- src/Core/Storage/Type/ExternalResource.php | 3 ++- src/Module/Proxy.php | 3 ++- src/Network/HTTPClient/Client/HttpClient.php | 6 +++--- src/Network/Probe.php | 2 +- src/Util/HTTPSignature.php | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Core/Storage/Type/ExternalResource.php b/src/Core/Storage/Type/ExternalResource.php index 23239965d1..3a1dc129fc 100644 --- a/src/Core/Storage/Type/ExternalResource.php +++ b/src/Core/Storage/Type/ExternalResource.php @@ -26,6 +26,7 @@ use Friendica\Core\Logger; use Friendica\Core\Storage\Exception\ReferenceStorageException; use Friendica\Core\Storage\Capability\ICanReadFromStorage; use Friendica\Network\HTTPClient\Client\HttpClient; +use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Util\HTTPSignature; /** @@ -54,7 +55,7 @@ class ExternalResource implements ICanReadFromStorage } try { - $fetchResult = HTTPSignature::fetchRaw($data->url, $data->uid, ['accept_content' => [HttpClient::ACCEPT_IMAGE]]); + $fetchResult = HTTPSignature::fetchRaw($data->url, $data->uid, [HttpClientOptions::ACCEPT_CONTENT => [HttpClient::ACCEPT_IMAGE]]); } catch (Exception $exception) { throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception); } diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index dfc8113a4b..751b4a2984 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -26,6 +26,7 @@ use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\DI; use Friendica\Network\HTTPClient\Client\HttpClient; +use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Network\HTTPException\NotModifiedException; use Friendica\Object\Image; use Friendica\Util\HTTPSignature; @@ -82,7 +83,7 @@ class Proxy extends BaseModule $request['url'] = str_replace(' ', '+', $request['url']); // Fetch the content with the local user - $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), ['accept_content' => [HttpClient::ACCEPT_IMAGE], 'timeout' => 10]); + $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClient::ACCEPT_IMAGE], 'timeout' => 10]); $img_str = $fetchResult->getBody(); if (!$fetchResult->isSuccess() || empty($img_str)) { diff --git a/src/Network/HTTPClient/Client/HttpClient.php b/src/Network/HTTPClient/Client/HttpClient.php index 792cc7965b..e8e77a6b01 100644 --- a/src/Network/HTTPClient/Client/HttpClient.php +++ b/src/Network/HTTPClient/Client/HttpClient.php @@ -267,9 +267,9 @@ class HttpClient implements ICanSendHttpRequests return $this->get( $url, [ - 'timeout' => $timeout, - 'accept_content' => $accept_content, - 'cookiejar' => $cookiejar + HttpClientOptions::TIMEOUT => $timeout, + HttpClientOptions::ACCEPT_CONTENT => $accept_content, + HttpClientOptions::COOKIEJAR => $cookiejar ] ); } diff --git a/src/Network/Probe.php b/src/Network/Probe.php index ceb684b70c..9ffbc3e0fb 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -932,7 +932,7 @@ class Probe { $xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20); - $curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => [$type]]); + $curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => $type]); if ($curlResult->isTimeout()) { self::$istimeout = true; return []; diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index faad39dde5..2a48267191 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -416,7 +416,7 @@ class HTTPSignature * @return \Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses CurlResult * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function fetchRaw($request, $uid = 0, $opts = ['accept_content' => [HttpClient::ACCEPT_JSON_AS]]) + public static function fetchRaw($request, $uid = 0, $opts = [HttpClientOptions::ACCEPT_CONTENT => [HttpClient::ACCEPT_JSON_AS]]) { $header = []; -- 2.39.5