Merge remote-tracking branch 'fetch/master'

This commit is contained in:
b2baccline
2020-08-25 22:25:16 +08:00
2 changed files with 14 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
/**
* @author Hccake
@@ -23,8 +24,11 @@ public class RepeatBodyRequestWrapper extends HttpServletRequestWrapper {
private final byte[] body;
private final Map<String, String[]> parameterMap;
public RepeatBodyRequestWrapper(HttpServletRequest request) {
super(request);
this.parameterMap = super.getParameterMap();
this.body = getByteBody(request);
}
@@ -69,4 +73,14 @@ public class RepeatBodyRequestWrapper extends HttpServletRequestWrapper {
return body;
}
/**
* 重写 getParameterMap() 方法 解决 undertow 中流被读取后,会进行标记,从而导致无法正确获取 body 中的表单数据的问题
* @see io.undertow.servlet.spec.HttpServletRequestImpl#readStarted
* @return Map<String, String[]> parameterMap
*/
@Override
public Map<String, String[]> getParameterMap() {
return parameterMap;
}
}

View File

@@ -104,9 +104,6 @@ public class LogUtils {
* @return 是否是multipart/form-data请求
*/
public boolean isMultipartContent(HttpServletRequest request) {
if (!HttpMethod.POST.name().equals(request.getMethod().toUpperCase())) {
return false;
}
// 获取Content-Type
String contentType = request.getContentType();
return (contentType != null) && (contentType.toLowerCase().startsWith("multipart/"));