最近我们在使用spring 3.2的servlet 3.0中使用异步功能,但是我们的ShallowEtagHeaderFilter根本没有效果,我认为必须是框架在我的内容处理之前刷新响应... 怎么解决?有人有经验吗?
答案 0 :(得分: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的业务逻辑。