@ Override public void sendRedirect ( final String location ) throws IOException { try { LOG . debug ( "redirecting to: {}" , location ) ; final InputStream is = externalResourceLocator . locate ( location ) ; IOUtils . copy ( is , servletOutputStream ) ; is . close ( ) ; servletOutputStream . close ( ) ; } catch ( final IOException e ) { LOG . warn ( "{}: Invalid response for location: {}" , e . getClass ( ) . getName ( ) , location ) ; throw e ; } }
By default redirect does not allow writing to output stream its content . In order to support this use - case we need to open a new connection and read the content manually .