Skip to content

Commit

Permalink
feat: allow RedirectionException
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Oct 6, 2023
1 parent 4cdc182 commit 2b7ed7b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions EMS/submission-bundle/src/Handler/HttpHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use EMS\SubmissionBundle\Response\NoHttpRequest;
use EMS\SubmissionBundle\Response\ResponseTransformer;
use EMS\SubmissionBundle\Twig\TwigRenderer;
use Symfony\Component\HttpClient\Exception\RedirectionException;
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class HttpHandler extends AbstractHandler
Expand All @@ -31,8 +32,13 @@ public function handle(HandleRequestInterface $handleRequest): HandleResponseInt
if (null !== $httpRequest->getIgnoreBodyValue() && $body === $httpRequest->getIgnoreBodyValue()) {
$handleResponse = new NoHttpRequest();
} else {
$httpResponse = $this->client->request($httpRequest->getMethod(), $httpRequest->getUrl(), $httpRequest->getHttpOptions());
$httpResponseContent = $httpResponse->getContent(true);
try {
$httpResponse = $this->client->request($httpRequest->getMethod(), $httpRequest->getUrl(), $httpRequest->getHttpOptions());
$httpResponseContent = $httpResponse->getContent(true);
} catch (RedirectionException $exception) {
$httpResponse = $exception->getResponse();
$httpResponseContent = '';
}
$handleResponse = new HttpHandleResponse($httpResponse, $httpResponseContent);
}

Expand Down

0 comments on commit 2b7ed7b

Please sign in to comment.