Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The name implies that default header values will be applied to the request which generally means that if the request doesn't specify a header value then the default is applied. For example:
defaultHeaderValue = ["Accept": "application/json"] httpClient.execute(new HttpGet(url)); //header should be application/json HttpGet get = new HttpGet(url); get.setHeader("Accept", "application/xml"); httpClient.execute(get); //header should be application/xml, *not* application/xml, application/json
A simple fix would be to add the following code snippet:
if(!request.containsHeader(defHeader.getName)) {
request.addHeader(defHeader);
}