Skip to content

Commit

Permalink
feat(app sec): Do not throw exception for appsec response 403 status …
Browse files Browse the repository at this point in the history
…code
  • Loading branch information
julienloizelet committed Sep 5, 2024
1 parent 517a6b0 commit 6d0afcc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Client/AbstractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected function requestAppSec(
new AppSecRequest($this->getAppSecUrl(), $method, $headers, $rawBody)
);

return $this->formatResponseBody($response);
return $this->formatResponseBody($response, ['403']);
}

/**
Expand All @@ -164,7 +164,7 @@ private function sendRequest(Request $request): Response
*
* @throws ClientException
*/
private function formatResponseBody(Response $response): array
private function formatResponseBody(Response $response, array $mutedCodes = ['404']): array
{
$statusCode = $response->getStatusCode();

Expand All @@ -182,7 +182,7 @@ private function formatResponseBody(Response $response): array

if ($statusCode < 200 || $statusCode >= 300) {
$message = "Unexpected response status code: $statusCode. Body was: " . str_replace("\n", '', $body);
if (404 !== $statusCode) {
if (!in_array($statusCode, $mutedCodes)) {
throw new ClientException($message, $statusCode);
}
}
Expand Down

0 comments on commit 6d0afcc

Please sign in to comment.