develooper Front page | perl.libwww | Postings from August 2003

Range header limitations in LWP/Protocol/

Matthew Eldridge
August 5, 2003 15:14
Range header limitations in LWP/Protocol/
Message ID:

I sent an earlier message indicating that I was having trouble with
failed HEAD requests that delegated down to Protocol/  My fix
was to just make HEAD requests blindly discard any errors (by eval'ing
the cleanup code) after successfully determining the file length.

In my particular application I know that I have the first START bytes,
I just don't know how long the rest of the file is, so I was calling
HEAD so I could add a header to the request like this:

  $request->header( Range => { "bytes=$START-$END" } );

However, after poking around a bit I found a much better solution to
my problem.  As documented here,

a valid range request need not include an ending byte #.  Thus I could
just say

  $request->header( Range => { "bytes=$START-" } );

and be done with it.

However, the code that handles the Range header in LWP/Protocol/
can't handle this case -- it insists that the starting and ending byte
numbers both be defined.

I've attached a patch that fixes this particular case.  The spec
defines some more variations on how the range header can be used, but
I don't know how many of them are workable or useful for ftp.


-Matthew Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About