Redirect response wrapper should commit response
This commit ensures that when using `sendRedirect`, the response wrapper behaves correctly with regards to the Servlet specification: 1. reset the response buffer to clear any partially written response 2. set the expected response HTTP headers 3. flush the buffer to commit the response Closes gh-29050
This commit is contained in:
parent
8dcb2a75fa
commit
298c9a6f1b
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.springframework.web.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
|
@ -44,9 +46,11 @@ final class RelativeRedirectResponseWrapper extends HttpServletResponseWrapper {
|
|||
|
||||
|
||||
@Override
|
||||
public void sendRedirect(String location) {
|
||||
public void sendRedirect(String location) throws IOException {
|
||||
resetBuffer();
|
||||
setStatus(this.redirectStatus.value());
|
||||
setHeader(HttpHeaders.LOCATION, location);
|
||||
flushBuffer();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue