From 8f7ca71d9162596ff0184de623765daf5a8c20fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E7=81=B6=E7=94=9F?= Date: Sun, 8 Jan 2023 22:59:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=8F=82=E6=95=B0=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=A4=B4=E5=90=8D=E7=A7=B0=E4=B8=8D=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../egzosn/pay/common/bean/NoticeParams.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/NoticeParams.java b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/NoticeParams.java index 54f59a6..6b19357 100644 --- a/pay-java-common/src/main/java/com/egzosn/pay/common/bean/NoticeParams.java +++ b/pay-java-common/src/main/java/com/egzosn/pay/common/bean/NoticeParams.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2021 the original Egan. + * Copyright 2017-2023 the original Egan. * email egzosn@gmail.com * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,19 +59,34 @@ public class NoticeParams { this.headers = headers; } + private T getValueMatchingKey(Map values, String key) { + T value = values.get(key); + if (null != value) { + return value; + } + + for (Map.Entry entry : values.entrySet()) { + if (entry.getKey().equalsIgnoreCase(key)) { + return entry.getValue(); + } + } + return null; + } + + public String getHeader(String name) { - List value = this.headers.get(name); + List value = getValueMatchingKey(headers, name); return (null == value || value.isEmpty()) ? null : value.get(0); } public Enumeration getHeaders(String name) { - List value = this.headers.get(name); + List value = getValueMatchingKey(headers, name); return (Collections.enumeration(value != null ? value : Collections.emptySet())); } public Enumeration getHeaderNames() { - if (null == headers){ - return Collections.enumeration(Collections.emptySet()); + if (null == headers) { + return Collections.enumeration(Collections.emptySet()); } return Collections.enumeration(this.headers.keySet()); }