mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +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) {
|
public Request form(final Map<String, Object> formMap) {
|
||||||
final AtomicBoolean isMultiPart = new AtomicBoolean(false);
|
final AtomicBoolean isMultiPart = new AtomicBoolean(false);
|
||||||
formMap.forEach((key, value) -> {
|
formMap.forEach((key, value) -> {
|
||||||
if (value instanceof File ||
|
if (hasMultipartValue(value)) {
|
||||||
value instanceof Path ||
|
|
||||||
value instanceof Resource ||
|
|
||||||
value instanceof InputStream ||
|
|
||||||
value instanceof Reader) {
|
|
||||||
isMultiPart.set(true);
|
isMultiPart.set(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -470,4 +466,25 @@ public class Request implements HeaderOperation<Request> {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return HttpUtil.toString(this);
|
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…
x
Reference in New Issue
Block a user