parent
570c5b34e6
commit
cfb29db278
|
@ -623,10 +623,15 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||
|
||||
@Override
|
||||
public void sendRedirect(String url) throws IOException {
|
||||
sendRedirect(url, HttpServletResponse.SC_MOVED_TEMPORARILY, true);
|
||||
}
|
||||
|
||||
// @Override - on Servlet 6.1
|
||||
public void sendRedirect(String url, int sc, boolean clearBuffer) throws IOException {
|
||||
Assert.state(!isCommitted(), "Cannot send redirect - response is already committed");
|
||||
Assert.notNull(url, "Redirect URL must not be null");
|
||||
setHeader(HttpHeaders.LOCATION, url);
|
||||
setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
|
||||
setStatus(sc);
|
||||
setCommitted(true);
|
||||
}
|
||||
|
||||
|
@ -775,7 +780,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||
|
||||
@Override
|
||||
public void setStatus(int status) {
|
||||
if (!this.isCommitted()) {
|
||||
if (!isCommitted()) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ class MockHttpServletResponseTests {
|
|||
response.setCharacterEncoding("UTF-8");
|
||||
assertThat(response.getContentType()).isEqualTo("test/plain;charset=UTF-8");
|
||||
assertThat(response.getHeader(CONTENT_TYPE)).isEqualTo("test/plain;charset=UTF-8");
|
||||
response.setCharacterEncoding(null);
|
||||
response.setCharacterEncoding((String) null);
|
||||
assertThat(response.getContentType()).isEqualTo("test/plain");
|
||||
assertThat(response.getHeader(CONTENT_TYPE)).isEqualTo("test/plain");
|
||||
assertThat(response.getCharacterEncoding()).isEqualTo(WebUtils.DEFAULT_CHARACTER_ENCODING);
|
||||
|
|
|
@ -623,10 +623,15 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||
|
||||
@Override
|
||||
public void sendRedirect(String url) throws IOException {
|
||||
sendRedirect(url, HttpServletResponse.SC_MOVED_TEMPORARILY, true);
|
||||
}
|
||||
|
||||
// @Override - on Servlet 6.1
|
||||
public void sendRedirect(String url, int sc, boolean clearBuffer) throws IOException {
|
||||
Assert.state(!isCommitted(), "Cannot send redirect - response is already committed");
|
||||
Assert.notNull(url, "Redirect URL must not be null");
|
||||
setHeader(HttpHeaders.LOCATION, url);
|
||||
setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
|
||||
setStatus(sc);
|
||||
setCommitted(true);
|
||||
}
|
||||
|
||||
|
@ -775,7 +780,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||
|
||||
@Override
|
||||
public void setStatus(int status) {
|
||||
if (!this.isCommitted()) {
|
||||
if (!isCommitted()) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
@ -785,6 +790,9 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||
return this.status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the error message used when calling {@link HttpServletResponse#sendError(int, String)}.
|
||||
*/
|
||||
@Nullable
|
||||
public String getErrorMessage() {
|
||||
return this.errorMessage;
|
||||
|
|
|
@ -679,6 +679,11 @@ class DefaultServerRequest implements ServerRequest {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
// @Override - on Servlet 6.1
|
||||
public void sendRedirect(String location, int sc, boolean clearBuffer) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDateHeader(String name, long date) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
Loading…
Reference in New Issue