2013-08-26 35 views

回答

0

在Spring 4.3.5參考ShallowEtagFilter的代碼片段,

protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) 
     throws ServletException, IOException { 

    HttpServletResponse responseToUse = response; 
    if (!isAsyncDispatch(request) && !(response instanceof ContentCachingResponseWrapper)) { 
     responseToUse = new HttpStreamingAwareContentCachingResponseWrapper(response, request); 
    } 

    filterChain.doFilter(request, responseToUse); 

    if (!isAsyncStarted(request) && !isContentCachingDisabled(request)) { 
     updateResponse(request, responseToUse); 
    } 
} 

/** 
    * Whether request processing is in asynchronous mode meaning that the 
    * response will not be committed after the current thread is exited. 
    * @param request the current request 
    * @since 3.2 
    * @see WebAsyncManager#isConcurrentHandlingStarted() 
    */ 
    protected boolean isAsyncStarted(HttpServletRequest request) { 
     return WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted(); 
    } 

當您使用異步servlet時,病情就不會得到滿足,這意味着產生ETAG的業務邏輯就不會被調用。

相關問題