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

Range header limitations in LWP/Protocol/ftp.pm

From:
Matthew Eldridge
Date:
August 5, 2003 15:14
Subject:
Range header limitations in LWP/Protocol/ftp.pm
Message ID:
16176.9800.68860.597979@radiance.Stanford.EDU

I sent an earlier message indicating that I was having trouble with
failed HEAD requests that delegated down to Protocol/ftp.pm.  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, 

  http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35

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/ftp.pm
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.

Thanks,

-Matthew




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About