You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Lukáš Křečan <lu...@krecan.net> on 2014/04/01 11:13:36 UTC
Heades in Async redirect
Hi,
I am using httpasyncclient 4.0.1 and I am setting custom Accept
header. The server returns 302 redirect, the client correctly follows
the location header and sends redirect. The trouble is, that Accept
header from the original request is not copied to the redirect so the
server returns unexpected Content-Type. Is it a bug or am I doing
something work?
Cheers
Lukas
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Heades in Async redirect
Posted by "Yoram Dayagi (Gmail)" <yo...@gmail.com>.
Hi,
Apparently, this is the behaviour of the client.
I did something like that, in order to copy the “Range” header:
builder.setRedirectStrategy(new DefaultRedirectStrategy() {
@Override
public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException {
HttpUriRequest redirectRequest = super.getRedirect(request, response, context);
// copy "Range" headers, if exist
Header[] rangeHeaders = request.getHeaders(HttpHeaders.RANGE);
if (rangeHeaders != null) {
for (Header header : rangeHeaders) {
redirectRequest.addHeader(header);
}
}
return redirectRequest;
}
});
Hope it’s the correct approach.
--
Yoram Dayagi (Gmail)
Sent with Airmail
On April 1, 2014 at 12:15:58 PM, Lukáš Křečan (lukas@krecan.net) wrote:
Hi,
I am using httpasyncclient 4.0.1 and I am setting custom Accept
header. The server returns 302 redirect, the client correctly follows
the location header and sends redirect. The trouble is, that Accept
header from the original request is not copied to the redirect so the
server returns unexpected Content-Type. Is it a bug or am I doing
something work?
Cheers
Lukas
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org