You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (JIRA)" <ji...@apache.org> on 2015/07/29 12:31:05 UTC
[jira] [Updated] (HTTPCLIENT-1671) RequestDefaultHeaders should
only be set if the header hasn't already been set
[ https://issues.apache.org/jira/browse/HTTPCLIENT-1671?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oleg Kalnichevski updated HTTPCLIENT-1671:
------------------------------------------
Fix Version/s: 5.0
> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org