Polishing
This commit is contained in:
parent
f117b804a8
commit
35e37f6b60
|
|
@ -24,9 +24,8 @@ import java.util.concurrent.TimeoutException;
|
|||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A {@link org.springframework.util.concurrent.ListenableFuture ListenableFuture}
|
||||
* whose value can be set via {@link #set(T)} or {@link #setException(Throwable)}.
|
||||
* It may also be cancelled.
|
||||
* A {@link ListenableFuture} whose value can be set via {@link #set(Object)}
|
||||
* or {@link #setException(Throwable)}. It may also get cancelled.
|
||||
*
|
||||
* <p>Inspired by {@code com.google.common.util.concurrent.SettableFuture}.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package org.springframework.web.filter;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
|
|
@ -46,6 +45,7 @@ import org.springframework.web.util.WebUtils;
|
|||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Brian Clozel
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.0
|
||||
*/
|
||||
|
|
@ -61,32 +61,37 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
|
|||
|
||||
private static final String STREAMING_ATTRIBUTE = ShallowEtagHeaderFilter.class.getName() + ".STREAMING";
|
||||
|
||||
|
||||
/** Checking for Servlet 3.0+ HttpServletResponse.getHeader(String) */
|
||||
private static final boolean servlet3Present =
|
||||
ClassUtils.hasMethod(HttpServletResponse.class, "getHeader", String.class);
|
||||
|
||||
private boolean writeWeakETag = false;
|
||||
|
||||
/**
|
||||
* Set whether the ETag value written to the response should be weak, as per rfc7232.
|
||||
* <p>Should be configured using an {@code <init-param>} for parameter name
|
||||
* "writeWeakETag" in the filter definition in {@code web.xml}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc7232#section-2.3">rfc7232 section-2.3</a>
|
||||
*/
|
||||
public boolean isWriteWeakETag() {
|
||||
return writeWeakETag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the ETag value written to the response should be weak, as per rfc7232.
|
||||
* Set whether the ETag value written to the response should be weak, as per RFC 7232.
|
||||
* <p>Should be configured using an {@code <init-param>} for parameter name
|
||||
* "writeWeakETag" in the filter definition in {@code web.xml}.
|
||||
* @since 4.3
|
||||
* @see <a href="https://tools.ietf.org/html/rfc7232#section-2.3">RFC 7232 section 2.3</a>
|
||||
*/
|
||||
public void setWriteWeakETag(boolean writeWeakETag) {
|
||||
this.writeWeakETag = writeWeakETag;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default value is "false" so that the filter may delay the generation of
|
||||
* an ETag until the last asynchronously dispatched thread.
|
||||
* Return whether the ETag value written to the response should be weak, as per RFC 7232.
|
||||
* @since 4.3
|
||||
*/
|
||||
public boolean isWriteWeakETag() {
|
||||
return this.writeWeakETag;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The default value is {@code false} so that the filter may delay the generation
|
||||
* of an ETag until the last asynchronously dispatched thread.
|
||||
*/
|
||||
@Override
|
||||
protected boolean shouldNotFilterAsyncDispatch() {
|
||||
|
|
|
|||
|
|
@ -41,22 +41,23 @@ public class ServletResponseMethodArgumentResolverTests {
|
|||
|
||||
private ServletResponseMethodArgumentResolver resolver;
|
||||
|
||||
private Method method;
|
||||
|
||||
private ModelAndViewContainer mavContainer;
|
||||
|
||||
private ServletWebRequest webRequest;
|
||||
|
||||
private MockHttpServletResponse servletResponse;
|
||||
|
||||
private ServletWebRequest webRequest;
|
||||
|
||||
private Method method;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
resolver = new ServletResponseMethodArgumentResolver();
|
||||
method = getClass().getMethod("supportedParams", ServletResponse.class, OutputStream.class, Writer.class);
|
||||
servletResponse = new MockHttpServletResponse();
|
||||
mavContainer = new ModelAndViewContainer();
|
||||
servletResponse = new MockHttpServletResponse();
|
||||
webRequest = new ServletWebRequest(new MockHttpServletRequest(), servletResponse);
|
||||
|
||||
method = getClass().getMethod("supportedParams", ServletResponse.class, OutputStream.class, Writer.class);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue