Do you know where your variables are? | |
PerlMonks |
Re: LWP: Downloading First 2KB of an HTML Fileby Aristotle (Chancellor) |
on Feb 22, 2003 at 00:17 UTC ( [id://237637]=note: print w/replies, xml ) | Need Help?? |
Of course, a Range header will fail in a lot of cases, where the webserver doesn't know ahead of time the size of the document it is going to transmit. In that case you can use the $ua->request($request, \&callback, 4096); form of the request method. LWP::UserAgent will then call your callback function as it downloads, passing it chunks of the specified length. Now the POD to LWP::UserAgent says this:
Obviously, the easiest route in this case is to request chunks of 2kb, and unconditionally die whenever the callback is called. That will do exactly what you want: load 2kb, then abort the request.
There you go. Makeshifts last the longest.
In Section
Seekers of Perl Wisdom
|
|