mirror of
https://github.com/friendica/friendica
synced 2024-12-22 23:20:16 +00:00
Fix http_code
usage in case of failures
This commit is contained in:
parent
58001c729f
commit
0d6884a8a9
2 changed files with 3 additions and 6 deletions
|
@ -146,11 +146,11 @@ class HTTPClient implements IHTTPClient
|
||||||
$exception->hasResponse()) {
|
$exception->hasResponse()) {
|
||||||
return new GuzzleResponse($exception->getResponse(), $url, $exception->getCode(), '');
|
return new GuzzleResponse($exception->getResponse(), $url, $exception->getCode(), '');
|
||||||
} else {
|
} else {
|
||||||
return new CurlResult($url, '', ['http_code' => $exception->getCode()], $exception->getCode(), '');
|
return new CurlResult($url, '', ['http_code' => 500], $exception->getCode(), '');
|
||||||
}
|
}
|
||||||
} catch (InvalidArgumentException | \InvalidArgumentException $argumentException) {
|
} catch (InvalidArgumentException | \InvalidArgumentException $argumentException) {
|
||||||
$this->logger->info('Invalid Argument for HTTP call.', ['url' => $url, 'method' => $method, 'exception' => $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 {
|
} finally {
|
||||||
$this->logger->debug('Request stop.', ['url' => $url, 'method' => $method]);
|
$this->logger->debug('Request stop.', ['url' => $url, 'method' => $method]);
|
||||||
$this->profiler->stopRecording();
|
$this->profiler->stopRecording();
|
||||||
|
|
|
@ -28,9 +28,6 @@ class HTTPClientTest extends MockedTest
|
||||||
new Response(301, ['Location' => 'https:///']),
|
new Response(301, ['Location' => 'https:///']),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$httpClient = DI::httpClient();
|
self::assertFalse(DI::httpClient()->get('https://friendica.local')->isSuccess());
|
||||||
$httpClient->get('https:///');
|
|
||||||
|
|
||||||
self::assertEquals(1,1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue