[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpclient-users
Subject:    Re: Will the request header "Range" be used for new (redirected) requests?
From:       thai ha-thanh <hathanhthai () yahoo ! com>
Date:       2008-02-17 23:43:45
Message-ID: 121471.13823.qm () web30505 ! mail ! mud ! yahoo ! com
[Download RAW message or body]

Thanks Roland, your reply helped me a lot! My code is working now. 

My new code is below:

        String url = \
"http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/R-3.3.1.1 \
-200710231652/eclipse-CVS-Client-SDK-3.3.1.1.zip&url=http://download.eclipse.org/eclip \
se/downloads/drops/R-3.3.1.1-200710231652/eclipse-CVS-Client-SDK-3.3.1.1.zip&mirror_id=1";
  HttpGet httpget = new HttpGet(url);
        List defaultHeaders = new ArrayList(1);
        defaultHeaders.add(new BasicHeader("Range", "bytes=100-"));
        httpget.getParams().setParameter(ClientPNames.DEFAULT_HEADERS, \
defaultHeaders);  HttpResponse response = httpClient.execute(httpget);

Regards,
Thai



----- Original Message ----
From: Roland Weber <ossfwot@dubioso.net>
To: HttpClient User Discussion <httpclient-users@hc.apache.org>
Sent: Monday, February 18, 2008 12:41:12 AM
Subject: Re: Will the request header "Range" be used for new (redirected) requests?

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






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

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic