Revert "Replace IHTTPResult for CurlResult usages"
authorPhilipp <admin@philipp.info>
Sun, 11 Oct 2020 21:26:17 +0000 (23:26 +0200)
committerPhilipp <admin@philipp.info>
Sun, 11 Oct 2020 21:26:17 +0000 (23:26 +0200)
This reverts commit 97167d7b

src/Model/GServer.php
src/Network/CurlResult.php
src/Network/IHTTPRequest.php
tests/src/Core/InstallerTest.php

index ac86ef3..323a23f 100644 (file)
@@ -30,7 +30,7 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Module\Register;
-use Friendica\Network\IHTTPResult;
+use Friendica\Network\CurlResult;
 use Friendica\Protocol\Diaspora;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
@@ -630,19 +630,18 @@ class GServer
        /**
         * Detect server type by using the nodeinfo data
         *
-        * @param string      $url        address of the server
-        * @param IHTTPResult $httpResult
-        *
+        * @param string     $url        address of the server
+        * @param CurlResult $curlResult
         * @return array Server data
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       private static function fetchNodeinfo(string $url, IHTTPResult $httpResult)
+       private static function fetchNodeinfo(string $url, CurlResult $curlResult)
        {
-               if (!$httpResult->isSuccess()) {
+               if (!$curlResult->isSuccess()) {
                        return [];
                }
 
-               $nodeinfo = json_decode($httpResult->getBody(), true);
+               $nodeinfo = json_decode($curlResult->getBody(), true);
 
                if (!is_array($nodeinfo) || empty($nodeinfo['links'])) {
                        return [];
index 1187e45..072ab15 100644 (file)
@@ -101,7 +101,7 @@ class CurlResult implements IHTTPResult
         *
         * @param string $url optional URL
         *
-        * @return IHTTPResult a CURL with error response
+        * @return CurlResult a CURL with error response
         * @throws InternalServerErrorException
         */
        public static function createErrorCurl($url = '')
index 3f9b7f2..3ebcc5d 100644 (file)
@@ -57,7 +57,7 @@ interface IHTTPRequest
         * @param string $accept_content  supply Accept: header with 'accept_content' as the value
         * @param string $cookiejar       Path to cookie jar file
         *
-        * @return IHTTPResult With all relevant information, 'body' contains the actual fetched content.
+        * @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 = '');
 
@@ -76,7 +76,7 @@ interface IHTTPRequest
         *                           'cookiejar' => path to cookie jar file
         *                           'header' => header array
         *
-        * @return IHTTPResult
+        * @return CurlResult
         */
        public function get(string $url, bool $binary = false, array $opts = []);
 
@@ -88,7 +88,7 @@ interface IHTTPRequest
         * @param array  $headers HTTP headers
         * @param int    $timeout The timeout in seconds, default system config value or 60 seconds
         *
-        * @return IHTTPResult The content
+        * @return CurlResult The content
         */
        public function post(string $url, $params, array $headers = [], int $timeout = 0);
 
index 37a754b..0087968 100644 (file)
@@ -25,7 +25,7 @@ namespace Friendica\Core;
 use Dice\Dice;
 use Friendica\Core\Config\Cache;
 use Friendica\DI;
-use Friendica\Network\IHTTPResult;
+use Friendica\Network\CurlResult;
 use Friendica\Network\IHTTPRequest;
 use Friendica\Test\MockedTest;
 use Friendica\Test\Util\VFSTrait;
@@ -297,14 +297,14 @@ class InstallerTest extends MockedTest
                $this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
 
                // Mocking the CURL Response
-               $IHTTPResult = \Mockery::mock(IHTTPResult::class);
-               $IHTTPResult
+               $curlResult = \Mockery::mock(CurlResult::class);
+               $curlResult
                        ->shouldReceive('getReturnCode')
                        ->andReturn('404');
-               $IHTTPResult
+               $curlResult
                        ->shouldReceive('getRedirectUrl')
                        ->andReturn('');
-               $IHTTPResult
+               $curlResult
                        ->shouldReceive('getError')
                        ->andReturn('test Error');
 
@@ -313,11 +313,11 @@ class InstallerTest extends MockedTest
                $networkMock
                        ->shouldReceive('fetchFull')
                        ->with('https://test/install/testrewrite')
-                       ->andReturn($IHTTPResult);
+                       ->andReturn($curlResult);
                $networkMock
                        ->shouldReceive('fetchFull')
                        ->with('http://test/install/testrewrite')
-                       ->andReturn($IHTTPResult);
+                       ->andReturn($curlResult);
 
                $this->dice->shouldReceive('create')
                     ->with(IHTTPRequest::class)
@@ -344,14 +344,14 @@ class InstallerTest extends MockedTest
                $this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
 
                // Mocking the failed CURL Response
-               $IHTTPResultF = \Mockery::mock(IHTTPResult::class);
-               $IHTTPResultF
+               $curlResultF = \Mockery::mock(CurlResult::class);
+               $curlResultF
                        ->shouldReceive('getReturnCode')
                        ->andReturn('404');
 
                // Mocking the working CURL Response
-               $IHTTPResultW = \Mockery::mock(IHTTPResult::class);
-               $IHTTPResultW
+               $curlResultW = \Mockery::mock(CurlResult::class);
+               $curlResultW
                        ->shouldReceive('getReturnCode')
                        ->andReturn('204');
 
@@ -360,11 +360,11 @@ class InstallerTest extends MockedTest
                $networkMock
                        ->shouldReceive('fetchFull')
                        ->with('https://test/install/testrewrite')
-                       ->andReturn($IHTTPResultF);
+                       ->andReturn($curlResultF);
                $networkMock
                        ->shouldReceive('fetchFull')
                        ->with('http://test/install/testrewrite')
-                       ->andReturn($IHTTPResultW);
+                       ->andReturn($curlResultW);
 
                $this->dice->shouldReceive('create')
                           ->with(IHTTPRequest::class)