|[jetty-users] Possible bug in 9.4 HttpServletResponse redirect?|
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?
Back to the top