bugfix:非 json 请求(文件上传)时,token 过期时,错误读取 request body 问题

This commit is contained in:
YunaiV
2024-04-22 23:31:57 +08:00
parent feb742e084
commit 9164fa0ffb
7 changed files with 14 additions and 19 deletions

View File

@@ -93,11 +93,19 @@ public class ServletUtils {
}
public static String getBody(HttpServletRequest request) {
return JakartaServletUtil.getBody(request);
// 只有在 json 请求在读取,因为只有 CacheRequestBodyFilter 才会进行缓存,支持重复读取
if (isJsonRequest(request)) {
return JakartaServletUtil.getBody(request);
}
return null;
}
public static byte[] getBodyBytes(HttpServletRequest request) {
return JakartaServletUtil.getBodyBytes(request);
// 只有在 json 请求在读取,因为只有 CacheRequestBodyFilter 才会进行缓存,支持重复读取
if (isJsonRequest(request)) {
return JakartaServletUtil.getBodyBytes(request);
}
return null;
}
public static String getClientIP(HttpServletRequest request) {