hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christophe Kualasoft" <christo...@kualasoft.com>
Subject Re: Using GetMethod with offset
Date Mon, 06 Jun 2005 13:29:41 GMT
Hi You can set the content range in a Get Method, code below works for me:

        private void addByteRangeHeader(Enclosure encl, GetMethod gMethod) {

            int fileLen = new Long(encl.getFile().length()).intValue();
            String contentRange = "bytes=" + new
Integer((fileLen)).toString()
                    + "-";

            Header head = new Header();
            head.setName("Range");
            head.setValue(contentRange);
            gMethod.addRequestHeader(head);
        }

Check for a:  HttpStatus.SC_PARTIAL_CONTENT

Cheers / Christophe

----- Original Message ----- 
From: "Peter Bleckmann" <blepe@xinit.org>
To: <httpclient-user@jakarta.apache.org>
Sent: Monday, June 06, 2005 7:26 PM
Subject: Using GetMethod with offset


> Hi List!
>
> I got a question about how to define an offset for the GetMethod.
> What i am doing so far is to generate
> an InputStream  using the getResponseBodyAsStream() method for
> reading a huge binary file from a
> web server. For some reason I don`t want to read the entire file but
> only a "small" subset of the data,
> starting somewhere in the file. Using the skip() method (or things
> like that) to reach the "point of interest"
> in the input stream is not what I want as will transfer all skipped
> bytes. So my question is, how to obtain
> an InputStream starting at a given offset.
>
> Thanks for any advice, Peter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>


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


Mime
View raw message