From 49377987a7fbdc4d07963cc0eb7665814e29a93b Mon Sep 17 00:00:00 2001 From: Rosen Silva Date: Wed, 18 Oct 2023 07:38:10 +0530 Subject: [PATCH] Add parameter to ignore case sensitive headers Related Issue: https://github.com/wso2/api-manager/issues/2219 --- .../synapse/transport/passthru/ClientWorker.java | 2 +- .../passthru/config/PassThroughConfigPNames.java | 5 +++++ .../passthru/config/PassThroughConfiguration.java | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ClientWorker.java b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ClientWorker.java index 4c0a841ae5..a5e8d59ecd 100644 --- a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ClientWorker.java +++ b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/ClientWorker.java @@ -181,7 +181,7 @@ public int compare(String o1, String o2) { }); for (Map.Entry headerEntry : headerEntries) { - if (headerMap.containsKey(headerEntry.getKey())) { + if (headerMap.containsKey(headerEntry.getKey()) && !conf.isIgnoreCaseSensitiveHeaders()) { excessHeaders.put(headerEntry.getKey(), headerMap.get(headerEntry.getKey())); } headerMap.put(headerEntry.getKey(), headerEntry.getValue()); diff --git a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfigPNames.java b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfigPNames.java index 931e1d32e4..57f65026d4 100644 --- a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfigPNames.java +++ b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfigPNames.java @@ -177,4 +177,9 @@ public interface PassThroughConfigPNames { * Defines whether viewing services are enabled or not */ public String BLOCK_SERVICE_LIST = "http.block_service_list"; + + /** + * Defines whether to ignore case-sensitive headers from excess headers map + */ + public String IGNORE_CASE_SENSITIVE_HEADERS = "ignore_case_sensitive_headers"; } diff --git a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfiguration.java b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfiguration.java index d1268e6fdd..6d739ec433 100644 --- a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfiguration.java +++ b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfiguration.java @@ -387,4 +387,14 @@ public String getPassThroughDefaultServiceName() { } return passThroughDefaultServiceName; } + + /** + * Get the value of the property to ignore case-sensitive headers from excess headers + * + * @return Value of the property + */ + public boolean isIgnoreCaseSensitiveHeaders() { + return ConfigurationBuilderUtil.getBooleanProperty(PassThroughConfigPNames.IGNORE_CASE_SENSITIVE_HEADERS, + false, props); + } }