in reply to How to read just part of a url's content

You mean just get part of the file located with the URL?

There is almost certainly a way to do it, since wget (et al) can be instructed to continue.

Personally, I can't find a single relevant option in LWP, LWP::UserAgent, HTTP::Request, HTTP::Headers, and more.

I'm very curious to see how how you would get a selected portion of a file with LWP. Someone will know.

UPDATE #1: Further investigation has revealed that you can set a "range" header with
$request_object->header( $field => $value ); but I haven't yet worked out the particulars of the header.

use strict; use LWP::UserAgent; use HTTP::Request; my $ua = LWP::UserAgent->new(); my $req1 = HTTP::Request->new(GET => $your_URL); $req1->header( Range => 'bytes=0-499' ); # bytes 0 through 499 my $req2 = HTTP::Request->new(GET => $your_URL); $req2->header( Range => 'bytes=500-' ); # bytes 500 onward my $res1 = $ua->request( $req1 => "file1.html" ); my $res2 = $ua->request( $req2 => "file2.html" ); # A byte range operation MAY specify a single range of bytes, or a set + of ranges within a # # ranges-specifier = byte-ranges-specifier # byte-ranges-specifier = bytes-unit "=" byte-range-set # byte-range-set = 1#( byte-range-spec | suffix-byte-range-spec + ) # byte-range-spec = first-byte-pos "-" [last-byte-pos] # first-byte-pos = 1*DIGIT # last-byte-pos = 1*DIGIT

-Paul

Replies are listed 'Best First'.
Re^2: How to read just part of a url's content
by ikegami (Patriarch) on May 29, 2007 at 19:56 UTC

    You mean just get part of the file located with the URL?

    No, "file" is a less accurate accurate word. The content identified by a URI is not necessarily a file.

      That's a semantic argument. Is a file a space on a hard drive? Is it a stream of bytes? A sector on a tape? There's an application where I work that describes a file as 100 variably sized blocks. My point was that the URL just describes the location of something. You already have it.

      -Paul