hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yoram Dayagi (Gmail)" <yor...@gmail.com>
Subject Re: Redirect erases header?
Date Mon, 17 Feb 2014 09:02:27 GMT
Found the answer: when building the HttpAsyncClient set a redirect strategy and add the appropriate

        HttpAsyncClientBuilder builder = HttpAsyncClients.custom();
        builder.setRedirectStrategy(new DefaultRedirectStrategy() {
            public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response,
HttpContext context) throws ProtocolException {
                HttpUriRequest redirectRequest = super.getRedirect(request, response,
                // copy “Range" headers, if exist
                Header[] rangeHeaders = request.getHeaders(“Range");
                if (rangeHeaders != null) {
                    for (Header header : rangeHeaders) {
                return redirectRequest;


Yoram Dayagi (Gmail)
Sent with Airmail

On February 16, 2014 at 5:06:34 PM, Yoram Dayagi (Gmail) (yoramd@gmail.com) wrote:

I’m using HttpAsyncClient to execute an async request.

I noticed that when requesting a GET request for a URL that redirects to another, a header
I put in the request ("Range: bytes=0-1000") is ignored and all content is returned in the

1. When accessing directly the redirected URL the execution is as expected (only first 1000
bytes are returned)
2. The response of the original URL doesn’t contain a header "Accept-Ranges: bytes”, where
as the response of the redirected URL does contain this header.

How can I overcome this problem?

Yoram Dayagi (Gmail)
Sent with Airmail
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message