This commit is contained in:
Looly
2024-03-08 11:38:31 +08:00
parent 0adc4fd329
commit f78e4fecb8
2 changed files with 46 additions and 1 deletions

View File

@@ -15,6 +15,8 @@ package org.dromara.hutool.http.client.engine.jdk;
import org.dromara.hutool.core.array.ArrayUtil;
import org.dromara.hutool.core.io.IoUtil;
import org.dromara.hutool.core.io.stream.EmptyInputStream;
import org.dromara.hutool.core.map.MapUtil;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.http.HttpException;
import org.dromara.hutool.http.HttpUtil;
@@ -94,7 +96,11 @@ public class JdkHttpResponse implements Response, Closeable {
@Override
public String header(final String name) {
final List<String> headerValues = this.headers.get(name);
List<String> headerValues = this.headers.get(name);
if(null == headerValues){
// issue#I96U4T根据RFC2616规范header的name不区分大小写
headerValues = MapUtil.firstMatchValue(this.headers, entry-> StrUtil.equalsIgnoreCase(name, entry.getKey()));
}
if (ArrayUtil.isNotEmpty(headerValues)) {
return headerValues.get(0);
}