SPR-7160 - ShallowEtagHeaderFilter not adding ETag

This commit is contained in:
Arjen Poutsma 2010-05-03 08:58:20 +00:00
parent 159f98728e
commit dd8c18188f
2 changed files with 5 additions and 5 deletions

View File

@ -113,8 +113,9 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
} }
/** /**
* Generate the ETag header value from the given response body byte array. <p>The default implementation generates an * Generate the ETag header value from the given response body byte array.
* MD5 hash. *
* <p>The default implementation generates an MD5 hash.
* *
* @param bytes the response bdoy as byte array * @param bytes the response bdoy as byte array
* @return the ETag header value * @return the ETag header value
@ -140,7 +141,7 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
private PrintWriter writer; private PrintWriter writer;
private int statusCode = -1; private int statusCode = HttpServletResponse.SC_OK;
private ShallowEtagResponseWrapper(HttpServletResponse response) { private ShallowEtagResponseWrapper(HttpServletResponse response) {
super(response); super(response);

View File

@ -31,7 +31,7 @@ import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
public class ShallowEtagHeaderFilterTest { public class ShallowEtagHeaderFilterTests {
private ShallowEtagHeaderFilter filter; private ShallowEtagHeaderFilter filter;
@ -85,7 +85,6 @@ public class ShallowEtagHeaderFilterTest {
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse) public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
throws IOException, ServletException { throws IOException, ServletException {
assertEquals("Invalid request passed", request, filterRequest); assertEquals("Invalid request passed", request, filterRequest);
((HttpServletResponse) filterResponse).setStatus(HttpServletResponse.SC_OK);
byte[] responseBody = "Hello World".getBytes("UTF-8"); byte[] responseBody = "Hello World".getBytes("UTF-8");
FileCopyUtils.copy(responseBody, filterResponse.getOutputStream()); FileCopyUtils.copy(responseBody, filterResponse.getOutputStream());
} }