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: setting headers for a async request
Date Fri, 29 Jul 2011 09:13:17 GMT
On Fri, 2011-07-29 at 10:54 +0200, Julien Vermillard wrote:
> Hi !
> I'm using the async http client for post & get methods, it's working
> fine until now.
> here my code :
> <code>
> clientMethod = new HttpAsyncPost(targetUrl, content, request.getContentType());
> httpclient.execute(clientMethod, new MyResponseConsumer(continuation),
> new FutureCallback<Boolean>() {
> ...
> </code>
> I would like to add header value in my requests, but I'm unable to
> find the way to do it in the API.
> Where I'm supposed to add my headers ?
> Julien

Hi Julien

If you do not mind upgrading to the snapshot, you can use the
HttpAsyncMethods#create() method to create an async producer from an
arbitrary HttpRequest instance.


With 4.0a2 you will have to override the HttpAsyncPost#createRequest
method in order to add custom headers to the request (which is clumsy).

Alternatively, you might want to use a protocol interceptor in order to
add custom headers to all outgoing requests. Protocol interceptors is
the recommended way of dealing with cross-cutting aspects of the HTTP
protocol in HttpCore.

Hope this helps


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

View raw message