Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to download a range of bytes?

by eserte (Deacon)
on Dec 26, 2007 at 23:27 UTC ( #659127=note: print w/replies, xml ) Need Help??


in reply to How to download a range of bytes?

This seems to work:
#!/usr/bin/perl -w use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $url = 'http://localhost/...'; $ua->default_headers->push_header(Range => "bytes=1000-2000"); my $response = $ua->get($url); my $content = $response->content(); warn length($content); warn $content;
To get the current content length of the object, you can do a HEAD before and look at the content-length header.

Replies are listed 'Best First'.
Re^2: How to download a range of bytes?
by Zeokat (Novice) on Dec 26, 2007 at 23:47 UTC
    The code works verrrrrrry good eserte. Big thanks. But new question arrive to my head, are there any way to know if the server have the abbility of "Accept-Ranges: bytes" ?? Thanks in advance.
      Try fetching with HEAD instead of GET to view the Accept* headers without getting the content itself

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://659127]
help
Chatterbox?
[1nickt]: Life is weird. Just reading about the iPhone battery problems and saw: 'It’s like calling water “dihydrogen monoxide”'

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2016-12-06 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (105 votes). Check out past polls.