|
1 | 1 | /*
|
2 |
| - * Copyright 2017-2021 the original Egan. |
| 2 | + * Copyright 2017-2023 the original Egan. |
3 | 3 |
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * 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)
|
59 | 59 | this.headers = headers;
|
60 | 60 | }
|
61 | 61 |
|
| 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 | + |
62 | 77 | public String getHeader(String name) {
|
63 |
| - List<String> value = this.headers.get(name); |
| 78 | + List<String> value = getValueMatchingKey(headers, name); |
64 | 79 | return (null == value || value.isEmpty()) ? null : value.get(0);
|
65 | 80 | }
|
66 | 81 |
|
67 | 82 | public Enumeration<String> getHeaders(String name) {
|
68 |
| - List<String> value = this.headers.get(name); |
| 83 | + List<String> value = getValueMatchingKey(headers, name); |
69 | 84 | return (Collections.enumeration(value != null ? value : Collections.<String>emptySet()));
|
70 | 85 | }
|
71 | 86 |
|
72 | 87 | public Enumeration<String> getHeaderNames() {
|
73 |
| - if (null == headers){ |
74 |
| - return Collections.enumeration(Collections.emptySet()); |
| 88 | + if (null == headers) { |
| 89 | + return Collections.enumeration(Collections.emptySet()); |
75 | 90 | }
|
76 | 91 | return Collections.enumeration(this.headers.keySet());
|
77 | 92 | }
|
|
0 commit comments