Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
laziness, impatience, and hubris
 
PerlMonks  

LWP Byte Limit

by vbrtrmn (Pilgrim)
on Aug 18, 2004 at 13:44 UTC ( [id://384052]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

vbrtrmn has asked for the wisdom of the Perl Monks concerning the following question:

Hey All, I'm dealing with some large XML files, which I only need the first few lines. I don't really want to get the whole file, is there a nice way, using LWP to only get the first say 5k? I'm using the really basic HTTP::Request...
use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->agent("Faux Browser/1.0"); my $req = HTTP::Request->new(GET=>$url); $req->content_type('application/x-www-form-urlencoded'); $req->content('query=libwww-perl&mode=dist'); my $res = $ua->request($req); if ($res->is_success) { # do stuff } else { # error out }

--
paul

Replies are listed 'Best First'.
Re: LWP Byte Limit
by Aristotle (Chancellor) on Aug 18, 2004 at 14:29 UTC
Re: LWP Byte Limit
by Fletch (Bishop) on Aug 18, 2004 at 14:30 UTC

    Theoretically you should be able to set the Content-Range header to the first chunk you want, but keep in mind that servers aren't required to implement handling this header (and may not be able to for things like dynamically generated documents). See section 14.16 of RFC 2616.

•Re: LWP Byte Limit
by merlyn (Sage) on Aug 18, 2004 at 14:57 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://384052]
Approved by davido
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.