]> git.mxchange.org Git - friendica.git/commitdiff
Fix `http_code` usage in case of failures
authorPhilipp <admin@philipp.info>
Sun, 29 Aug 2021 12:05:38 +0000 (14:05 +0200)
committerPhilipp <admin@philipp.info>
Sun, 29 Aug 2021 12:05:38 +0000 (14:05 +0200)
src/Network/HTTPClient.php
tests/src/Network/HTTPClientTest.php

index 4467b2dea2576bf8eb0ac0cc2e1af126ce749581..004af57f9a34eb83f88d12e854035a0b3ec30b10 100644 (file)
@@ -146,11 +146,11 @@ class HTTPClient implements IHTTPClient
                                $exception->hasResponse()) {
                                return new GuzzleResponse($exception->getResponse(), $url, $exception->getCode(), '');
                        } else {
-                               return new CurlResult($url, '', ['http_code' => $exception->getCode()], $exception->getCode(), '');
+                               return new CurlResult($url, '', ['http_code' => 500], $exception->getCode(), '');
                        }
                } catch (InvalidArgumentException | \InvalidArgumentException $argumentException) {
                        $this->logger->info('Invalid Argument for HTTP call.', ['url' => $url, 'method' => $method, 'exception' => $argumentException]);
-                       return new CurlResult($url, '', ['http_code' => $argumentException->getCode()], $argumentException->getCode(), $argumentException->getMessage());
+                       return new CurlResult($url, '', ['http_code' => 500], $argumentException->getCode(), $argumentException->getMessage());
                } finally {
                        $this->logger->debug('Request stop.', ['url' => $url, 'method' => $method]);
                        $this->profiler->stopRecording();
index 89f2510f304ef4a469fcb679d480b247894b5303..0e3f74c096d5efe55272d3eba5677306c7825df8 100644 (file)
@@ -28,9 +28,6 @@ class HTTPClientTest extends MockedTest
                        new Response(301, ['Location' => 'https:///']),
                ]));
 
-               $httpClient = DI::httpClient();
-               $httpClient->get('https:///');
-
-               self::assertEquals(1,1);
+               self::assertFalse(DI::httpClient()->get('https://friendica.local')->isSuccess());
        }
 }