mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -14,12 +14,15 @@ package org.dromara.hutool.http.client;
|
|||||||
|
|
||||||
import org.dromara.hutool.core.array.ArrayUtil;
|
import org.dromara.hutool.core.array.ArrayUtil;
|
||||||
import org.dromara.hutool.core.collection.CollUtil;
|
import org.dromara.hutool.core.collection.CollUtil;
|
||||||
|
import org.dromara.hutool.core.collection.ListUtil;
|
||||||
import org.dromara.hutool.core.map.MapUtil;
|
import org.dromara.hutool.core.map.MapUtil;
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
import org.dromara.hutool.core.text.StrUtil;
|
||||||
import org.dromara.hutool.http.meta.HeaderName;
|
import org.dromara.hutool.http.meta.HeaderName;
|
||||||
|
|
||||||
import java.net.HttpCookie;
|
import java.net.HttpCookie;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,6 +136,25 @@ public interface HeaderOperation<T extends HeaderOperation<T>> {
|
|||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置请求头<br>
|
||||||
|
* 覆盖原有请求头,请求参数为普通Map,简化使用
|
||||||
|
*
|
||||||
|
* @param headerMap 请求头
|
||||||
|
* @return this
|
||||||
|
* @author dazer
|
||||||
|
*/
|
||||||
|
default T header(final Map<String, String> headerMap) {
|
||||||
|
if (MapUtil.isEmpty(headerMap)) {
|
||||||
|
return (T) this;
|
||||||
|
}
|
||||||
|
final Map<String, List<String>> headerMaps = new LinkedHashMap<>(headers().size());
|
||||||
|
headerMap.forEach((key, value) -> {
|
||||||
|
headerMaps.put(key, ListUtil.of(value));
|
||||||
|
});
|
||||||
|
return header(headerMaps, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置contentType
|
* 设置contentType
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user