]> git.mxchange.org Git - friendica.git/commitdiff
Use "HttpClientOptions"
authorMichael <heluecht@pirati.ca>
Tue, 29 Mar 2022 08:57:38 +0000 (08:57 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 29 Mar 2022 08:57:38 +0000 (08:57 +0000)
src/Core/Storage/Type/ExternalResource.php
src/Module/Proxy.php
src/Network/HTTPClient/Client/HttpClient.php
src/Network/Probe.php
src/Util/HTTPSignature.php

index 23239965d1463c74dab4837b53b89593a7099ebc..3a1dc129fc02ae40a10d2602953d03f3e9aa269a 100644 (file)
@@ -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);
                }
index dfc8113a4bf3e6ef969520d7be3f199527adf5f3..751b4a29846dbf3fe17348f9aedf305fd49f20ad 100644 (file)
@@ -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)) {
index 792cc7965b0463a3ecdab2dbb8685c3277b9de36..e8e77a6b017ee12512505c9845c98ccfb0ead428 100644 (file)
@@ -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
                        ]
                );
        }
index ceb684b70c740ca12809e66981f34f0b77d24e12..9ffbc3e0fb95fba8bd0b1aedd67e88db4142d237 100644 (file)
@@ -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 [];
index faad39dde5115c06bcc27c7aef5dcfc14dbe9a53..2a48267191d4163d907cf9fe8984e32fc34ccf16 100644 (file)
@@ -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 = [];