[
https://issues.apache.org/jira/browse/HTTPCLIENT-1671?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Oleg Kalnichevski resolved HTTPCLIENT-1671.
-------------------------------------------
Resolution: Fixed
Fixed in SVN trunk.
Oleg
> RequestDefaultHeaders should only be set if the header hasn't already been set
> ------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-1671
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1671
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Reporter: Steve Davids
> Fix For: 5.0
>
>
> 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:
> {code}
> 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
> {code}
> A simple fix would be to add the following code snippet:
> {code}
> if(!request.containsHeader(defHeader.getName)) {
> request.addHeader(defHeader);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]