diff options
author | Marek Szwałkiewicz <marek.szwalkiewicz@external.t-mobile.pl> | 2023-03-02 12:43:50 +0100 |
---|---|---|
committer | Marek Szwałkiewicz <marek.szwalkiewicz@external.t-mobile.pl> | 2023-03-03 12:42:35 +0100 |
commit | 508489a4ea7000b9e24cdb0ea48f5357010d783e (patch) | |
tree | d0ae300483b4fb943194ce8f0535a19eb9c1b8f5 /sdc-distribution-client/src/main/java/org/onap/sdc/http/HttpRequestFactory.java | |
parent | 928348966d924f7cf41077f98ab6665ea6aec512 (diff) |
Enable case insensitive matching of http headers
This change creates simple case insensitive map implementation that
is used in HttpSdcResponse class to store the response headers.
Generally HTTP headers are supposed to be case insensitive and
sometimes get transformed (in our case - by istio sidecar) to lower case.
With this change lower case will still be matched and the original
behaviour will not break.
Issue-ID: SDC-4233
Signed-off-by: Marek Szwałkiewicz <marek.szwalkiewicz@external.t-mobile.pl>
Change-Id: I1cb9d9e75ff656ccb12c690c553bccc672332a12
Diffstat (limited to 'sdc-distribution-client/src/main/java/org/onap/sdc/http/HttpRequestFactory.java')
-rw-r--r-- | sdc-distribution-client/src/main/java/org/onap/sdc/http/HttpRequestFactory.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sdc-distribution-client/src/main/java/org/onap/sdc/http/HttpRequestFactory.java b/sdc-distribution-client/src/main/java/org/onap/sdc/http/HttpRequestFactory.java index 9e2f3ee..ab4bd29 100644 --- a/sdc-distribution-client/src/main/java/org/onap/sdc/http/HttpRequestFactory.java +++ b/sdc-distribution-client/src/main/java/org/onap/sdc/http/HttpRequestFactory.java @@ -19,15 +19,16 @@ */ package org.onap.sdc.http; + import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.message.BasicHeader; +import org.onap.sdc.utils.CaseInsensitiveMap; import java.util.Base64; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; public class HttpRequestFactory { @@ -40,14 +41,14 @@ public class HttpRequestFactory { this.authHeaderValue = "Basic " + Base64.getEncoder().encodeToString(createAuthHeaderData(user, password)); } - public HttpGet createHttpGetRequest(String url, Map<String, String> headersMap) { + public HttpGet createHttpGetRequest(String url, CaseInsensitiveMap<String, String> headersMap) { HttpGet httpGet = new HttpGet(url); httpGet.setHeaders(createHttpRequestHeaders(headersMap, authHeaderValue)); return httpGet; } - public HttpPost createHttpPostRequest(String url, Map<String, String> headersMap, HttpEntity entity) { + public HttpPost createHttpPostRequest(String url, CaseInsensitiveMap<String, String> headersMap, HttpEntity entity) { HttpPost httpPost = new HttpPost(url); httpPost.setHeaders(createHttpRequestHeaders(headersMap, authHeaderValue)); httpPost.setEntity(entity); @@ -55,7 +56,7 @@ public class HttpRequestFactory { return httpPost; } - private Header[] createHttpRequestHeaders(Map<String, String> headersMap, String authorizationValue) { + private Header[] createHttpRequestHeaders(CaseInsensitiveMap<String, String> headersMap, String authorizationValue) { final List<Header> headers = headersMap.entrySet().stream() .map(it -> new BasicHeader(it.getKey(), it.getValue())) .collect(Collectors.toList()); |