hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Issue with replacing default header value
Date Fri, 22 Jul 2011 12:24:48 GMT
On Thu, 2011-07-21 at 14:53 +0200, Daniel Holm wrote:
> Hello everyone!
> I'm trying to replace the value of some of my default headers on a per
> request basis, but I'm not sure how to do this.
> I'm setting the default headers on the client using :
> client.getParams().setParameter(ClientPNames.DEFAULT_HEADERS, headers);
> On some requests I need to replace the value of some of the default headers,
> I do this like so:
> request.setHeader(HttpHeaders.ACCEPT, "application/json");
> When executing the request it has duplicate headers, one with the default
> value and one with the new value. I would rather want to replace the default
> value with the new one, how do I do this?
> /Daniel


The RequestDefaultHeaders protocol interceptor only adds fields but
never replaces those that are already there.


You need to remove the RequestDefaultHeaders interceptor and replace it
with a custom one if you want default headers to be handled differently.


To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message