Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Possible bug in 9.4 HttpServletResponse redirect?

Sorry for being loud: I forgot to mention that both body copying actions are only performed when a body is actually available (either Content-Length or Transfer-Encoding). So in case of a redirect HttpServletResponse#getOutputStream is never called.



On 01/05/2017 04:14 PM, Silvio Bierman wrote:
Hello all,

With Jetty 9.4 I experience failure of some code that used to work with previous Jetty versions. But since I am unsure if my code is valid I want to check here first.

My code is supposed to proxy an incoming request by forwarding it to another server (using HttpURLConnection) and then pass back the result to the response. In pseudo-code and somewhat simplified it does something like:

- forward all headers from HttpServletRequest#getHeaderNames + HttpServletRequest#getHeaders via HttpURLConnection#addRequestProperty - forward request body from HttpServletRequest#getInputStream to HttpURLConnection#getOutputStream - pass back all headers from HttpURLConnection#getHeaderFields to HttpServletResponse#addHeader - pass back response body from HttpURLConnection#getInputStream to HttpServletResponse#getOutputStream
- HttpServletResponse#sendError(HttpURLConnection#getResponseCode)

Note that there is no special handling for redirects since passing back the Location header and then sendError(302) used to be OK.

Using Jetty 9.4 this no longer works. Setting the Location header and then sendError(302) does not give a redirect. Only if I explicitly handle response code 302 and do HttpServletResponse#sendRedirect(location) does the redirect work.

Reverting to 9.3 solves the issue. But since I do not know if my code is valid I am not sure this signifies a bug in 9.4. Would anyone like to comment on this?



jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top