|
@@ -250,12 +250,12 @@ public final class HttpUtils {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 判断是否有请求体
|
|
|
+ * 判断是否是请求体类型
|
|
|
*
|
|
|
* @param request 请求对象
|
|
|
* @return true/false
|
|
|
*/
|
|
|
- public static boolean hasBody(@NonNull ServletRequest request) {
|
|
|
+ public static boolean isBodyType(@NonNull ServletRequest request) {
|
|
|
if (isJsonBody(request)) {
|
|
|
return true;
|
|
|
} else if (!(request instanceof HttpServletRequest)) {
|
|
@@ -273,18 +273,21 @@ public final class HttpUtils {
|
|
|
*/
|
|
|
public static boolean isJsonBody(@NonNull ServletRequest request) {
|
|
|
String type = request.getContentType();
|
|
|
- return StringUtils.notEmpty(type) && type.contains(MediaType.APPLICATION_JSON_VALUE);
|
|
|
+ return StringUtils.notEmpty(type) && type.startsWith(MediaType.APPLICATION_JSON_VALUE);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 判断是否是文件流请求体
|
|
|
+ * 判断是否是数据流请求体
|
|
|
*
|
|
|
* @param request 请求对象
|
|
|
* @return true/false
|
|
|
*/
|
|
|
- public static boolean isMultipartBody(@NonNull ServletRequest request) {
|
|
|
+ public static boolean isStreamBody(@NonNull ServletRequest request) {
|
|
|
String type = request.getContentType();
|
|
|
- return StringUtils.notEmpty(type) && type.startsWith("multipart/");
|
|
|
+ return StringUtils.notEmpty(type) && (type.startsWith("image/") || type.startsWith("audio/")
|
|
|
+ || type.startsWith("video/") || type.startsWith("multipart/") || type.startsWith("application/pdf")
|
|
|
+ || type.startsWith("application/zip") || type.startsWith("application/vnd.")
|
|
|
+ || type.startsWith("application/grpc") || type.startsWith("application/octet-stream"));
|
|
|
}
|
|
|
|
|
|
/**
|