mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
[MNT-23241] Prevent duplicated default headers if key/value pair is already in the request, otherwise, header is added (#1454)
* [MNT-23241] Prevent duplicated default headers if key/value pair is already in the request, otherwise, header is added
This commit is contained in:
@@ -21,6 +21,7 @@ package org.alfresco.httpclient;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.httpclient.Header;
|
||||
import org.apache.commons.httpclient.HostConfiguration;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
@@ -57,7 +58,12 @@ public class RequestHeadersHttpClient extends HttpClient
|
||||
if (defaultHeaders != null)
|
||||
{
|
||||
defaultHeaders.forEach((k,v) -> {
|
||||
method.addRequestHeader(k, v);
|
||||
Header h = method.getRequestHeader(k);
|
||||
boolean add = h == null || h.getValue() == null || !h.getValue().equals(v);
|
||||
if (add)
|
||||
{
|
||||
method.addRequestHeader(k, v);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user