Skip to content

Commit 8f7ca71

Browse files
author
郑灶生
committed
通知参数请求头名称不区分大小写
1 parent db34cb0 commit 8f7ca71

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

pay-java-common/src/main/java/com/egzosn/pay/common/bean/NoticeParams.java

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2021 the original Egan.
2+
* Copyright 2017-2023 the original Egan.
33
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -59,19 +59,34 @@ public NoticeParams(Map<String, Object> body, Map<String, List<String>> headers)
5959
this.headers = headers;
6060
}
6161

62+
private <T> T getValueMatchingKey(Map<String, T> values, String key) {
63+
T value = values.get(key);
64+
if (null != value) {
65+
return value;
66+
}
67+
68+
for (Map.Entry<String, T> entry : values.entrySet()) {
69+
if (entry.getKey().equalsIgnoreCase(key)) {
70+
return entry.getValue();
71+
}
72+
}
73+
return null;
74+
}
75+
76+
6277
public String getHeader(String name) {
63-
List<String> value = this.headers.get(name);
78+
List<String> value = getValueMatchingKey(headers, name);
6479
return (null == value || value.isEmpty()) ? null : value.get(0);
6580
}
6681

6782
public Enumeration<String> getHeaders(String name) {
68-
List<String> value = this.headers.get(name);
83+
List<String> value = getValueMatchingKey(headers, name);
6984
return (Collections.enumeration(value != null ? value : Collections.<String>emptySet()));
7085
}
7186

7287
public Enumeration<String> getHeaderNames() {
73-
if (null == headers){
74-
return Collections.enumeration(Collections.emptySet());
88+
if (null == headers) {
89+
return Collections.enumeration(Collections.emptySet());
7590
}
7691
return Collections.enumeration(this.headers.keySet());
7792
}

0 commit comments

Comments
 (0)