fix(log): 修复构建请求可重复读流后过滤文件流导致的错误问题

This commit is contained in:
liquor
2025-03-26 14:41:36 +00:00
committed by Charles7c
parent e294d69cdb
commit 1613374fcc
4 changed files with 20 additions and 9 deletions

View File

@@ -23,6 +23,7 @@ import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.util.UriUtils;
import top.continew.starter.core.constant.StringConstants;
import top.continew.starter.log.http.RecordableHttpRequest;
import top.continew.starter.web.util.RepeatReadRequestWrapper;
import java.net.URI;
import java.net.URISyntaxException;
@@ -79,8 +80,11 @@ public final class RecordableServletHttpRequest implements RecordableHttpRequest
@Override
public String getBody() {
String body = JakartaServletUtil.getBody(request);
return JSONUtil.isTypeJSON(body) ? body : null;
if (request instanceof RepeatReadRequestWrapper wrapper && !wrapper.isMultipartContent(request)) {
String body = JakartaServletUtil.getBody(request);
return JSONUtil.isTypeJSON(body) ? body : null;
}
return null;
}
@Override

View File

@@ -48,7 +48,13 @@ public class AccessLogUtils {
}
// 参数为空返回空
Map<String, Object> params = request.getParam();
Map<String, Object> params;
try {
params = request.getParam();
} catch (Exception e) {
return null;
}
if (ObjectUtil.isEmpty(params) || params.isEmpty()) {
return null;
}