mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
add test
This commit is contained in:
parent
8f55ac21d6
commit
c36669bd0b
@ -348,11 +348,7 @@ public class Request implements HeaderOperation<Request> {
|
||||
public Request form(final Map<String, Object> formMap) {
|
||||
final AtomicBoolean isMultiPart = new AtomicBoolean(false);
|
||||
formMap.forEach((key, value) -> {
|
||||
if (value instanceof File ||
|
||||
value instanceof Path ||
|
||||
value instanceof Resource ||
|
||||
value instanceof InputStream ||
|
||||
value instanceof Reader) {
|
||||
if (hasMultipartValue(value)) {
|
||||
isMultiPart.set(true);
|
||||
}
|
||||
});
|
||||
@ -470,4 +466,25 @@ public class Request implements HeaderOperation<Request> {
|
||||
public String toString() {
|
||||
return HttpUtil.toString(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查form表单中的对象是否为Multipart对象
|
||||
* @param value 对象
|
||||
* @return 是否为Multipart对象
|
||||
*/
|
||||
private static boolean hasMultipartValue(final Object value){
|
||||
if(value instanceof Iterable){
|
||||
for (final Object subValue : (Iterable<?>) value) {
|
||||
if(hasMultipartValue(subValue)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value instanceof File ||
|
||||
value instanceof Path ||
|
||||
value instanceof Resource ||
|
||||
value instanceof InputStream ||
|
||||
value instanceof Reader;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user