You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Steve Davids (JIRA)" <ji...@apache.org> on 2015/07/28 18:23:05 UTC
[jira] [Created] (HTTPCLIENT-1671) RequestDefaultHeaders should
only be set if the header hasn't already been set
Steve Davids created HTTPCLIENT-1671:
----------------------------------------
Summary: 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
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