Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Determining Content-Length when there is no Content-Length header

by jae_63 (Beadle)
on Apr 14, 2011 at 15:51 UTC ( #899467=note: print w/replies, xml ) Need Help??


in reply to Re: Determining Content-Length when there is no Content-Length header
in thread Determining Content-Length when there is no Content-Length header

OK, this is a very old thread, but I looked at this thread when searching for some information on a related problem, and now that I've solved it I think it should be posted here since Googling "Perl CURLOPT_RANGE" doesn't currently return any useful hits.

OK, the bottom line is that if you want to fetch a piece of a remote file using Perl you can take the WWW:Curl package

http://search.cpan.org/~szbalint/WWW-Curl-4.15/lib/WWW/Curl.pm

and modify the first example to include the lines

my $firstbyte = 50; my $lastbyte = 100; $curl->setopt(CURLOPT_RANGE,"$firstbyte-$lastbyte");

So the OP could use this technique to see whether, e.g. he's able to successfully fetch the 1,000,000th byte of a remote file. If he can fetch it, then he might decide not to try to download that file.

I hope that this info is useful to someone.

  • Comment on Re^2: Determining Content-Length when there is no Content-Length header
  • Download Code

Replies are listed 'Best First'.
Re^3: Determining Content-Length when there is no Content-Length header
by afoken (Abbot) on Apr 14, 2011 at 16:47 UTC

    Nice idea, but not all web servers / web applications support byte ranges. I think the proper behaviour for a web server is to ignore the unknown / unsupported header and send the entire resource -- which is clearly not what the OP wanted. See also Re: Determining Content-Length when there is no Content-Length header

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://899467]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2017-10-20 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (259 votes). Check out past polls.

    Notices?