<p dir="auto">Hello All,</p>
<p dir="auto">In a project that I am working on, we are using Symfony as a middleware between the Java WebService and the browser.</p>
<p dir="auto">Strangely Symfony converts a 201 response received from the WebService to a 302 Redirect.</p>
<p dir="auto">I am not sure if this is the reason why this is happening.<br>
<a href="https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Response.php#L1129">https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Response.php#L1129</a></p>
<p dir="auto"><a href="https://tools.ietf.org/html/rfc7231#section-7.1.2" rel="nofollow">https://tools.ietf.org/html/rfc7231#section-7.1.2</a></p>
<p dir="auto">Any suggestions would be of great help.<br>
Thanks in advance.</p>
<h2 dir="auto">Context</h2>
<p dir="auto">I have a listener on <code class="notranslate">KernelEvents::REQUEST</code> doing some checks related to the current request (to be precise I am validating its format against a swagger spec file).</p>
<h2 dir="auto">Issue</h2>
<p dir="auto">When an exception occurred, the HttpKernel's <code class="notranslate">ExceptionListener</code> duplicates the request (without the query and request arguments), changes the method to <code class="notranslate">GET</code> and then call <code class="notranslate">$kernel-&gt;handle()</code>.<br>
This request will be handled by my <code class="notranslate">KernelEvents::REQUEST</code> listener which will throw an exception because the Request is not valid from a domain point of view.</p>
<h2 dir="auto">Solution</h2>
<p dir="auto">Do not use a sub-request or forge a brand new request against a reserved endpoint.</p>
<p dir="auto">What do you think?</p>