mirror of
https://github.com/YunaiV/ruoyi-vue-pro.git
synced 2025-10-30 01:57:37 +08:00
Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/ruoyi-vue-pro
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.framework.web.core.filter;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
@ -16,6 +17,14 @@ import java.io.IOException;
|
||||
*/
|
||||
public class CacheRequestBodyFilter extends OncePerRequestFilter {
|
||||
|
||||
/**
|
||||
* 需要排除的 URI
|
||||
*
|
||||
* 1. 排除 Spring Boot Admin 相关请求,避免客户端连接中断导致的异常。
|
||||
* 例如说:<a href="https://github.com/YunaiV/ruoyi-vue-pro/issues/795">795 ISSUE</a>
|
||||
*/
|
||||
private static final String[] IGNORE_URIS = {"/admin", "/actuator"};
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
|
||||
throws IOException, ServletException {
|
||||
@ -24,7 +33,13 @@ public class CacheRequestBodyFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotFilter(HttpServletRequest request) {
|
||||
// 只处理 json 请求内容
|
||||
// 1. 校验是否为排除的 URL
|
||||
String requestURI = request.getRequestURI();
|
||||
if (StrUtil.containsAny(requestURI, IGNORE_URIS)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. 只处理 json 请求内容
|
||||
return !ServletUtils.isJsonRequest(request);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user