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 thai ha-thanh <ha...@yahoo.com> on 2008/02/17 17:32:04 UTC

Will the request header "Range" be used for new (redirected) requests?

Hi all,

I'm using httpclient-4.0-alpha2.jar and httpcore-4.0-alpha6.jar to download a zip file from a server. My problem is when I try to download part of the zip file (using Get request, Range header), and the server replies with a '302 Found' response, httpclient automatically submits a new GET request (this is what I expected) but the Range header is not used for the new GET request. As a result, I receive a response '200 OK' instead the response '206 Partial Content'.

My question is if this behavior is correct or a bug? I don't find any documents from Internet about the expected behavior in this case, but I believe that when httpclient follows a new location, it should send the headers of the old request to the new location.

Attached is my sample program (Main1.java) and the log printed by httpclient 4.0-alpha6 (log.txt). 

Thanks for your help.

Regards,
Thai





      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

Re: Will the request header "Range" be used for new (redirected) requests?

Posted by Roland Weber <os...@dubioso.net>.
thai ha-thanh wrote:
> Hi all,
> 
> I'm using httpclient-4.0-alpha2.jar and httpcore-4.0-alpha6.jar to download
> a zip file from a server. My problem is when I try to download part of the
 > zip file (using Get request, Range header), and the server replies with a
> '302 Found' response, httpclient automatically submits a new GET request
> (this is what I expected) but the Range header is not used for the new GET
> request. As a result, I receive a response '200 OK' instead the response
 > '206 Partial Content'.
> 
> My question is if this behavior is correct or a bug?

Works as designed. HttpClient doesn't know about your custom headers
and will not include them in the followup request. Options for solving
your problem:

1. disable automatic redirect handling and generate the followup request
    in your application, including the Range header
2. instead of setting the Range header directly on the method, add it to
    the "default header" parameter on the method level. We fixed a bug
    there in alpha2, so it is working correctly now:
    http://issues.apache.org/jira/browse/HTTPCLIENT-693

> I don't find any documents from Internet about the expected behavior in this case,

There are none except those we write ourselves. Specifications for browsers
do not apply, since HttpClient is not a browser. Specification of the Range
header says that it is optional, hence ignoring/dropping it is correct.

> but I believe that when httpclient follows a new location, it should
> send the headers of the old request to the new location.

HttpClient has no idea whatsoever which of the old headers make sense
for the redirected request and which don't. Copying headers can create
just as many problems than not copying them, but for different people.

> Attached is my sample program (Main1.java) and the log printed by
> httpclient 4.0-alpha6 (log.txt). 

Attachments are filtered by the mailing list server.
HttpClient 4.0 is at alpha2, with alpha3 coming up shortly.
IIRC, client alpha2 is running on core alpha6.

hope that helps,
   Roland


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