The key point i was trying to make, is that if your motivation for limiting the size is that you only want to make sure the links are valid (or check the size of the remote content, or find out if it has moved, etc...) you may want to rethink your problem.
A GET request is designed to return all of the data, where as a HEAD request is designed to only ask the server if the item exists, and get back basic meta-data about it. You could change one single line from your existing code (replace "GET" with "HEAD") and achieve yoru desired result. or you could eliminate most of your code alltogether, and re-use the existing functionality provided by LWP.
(As merlyn pointed out, it is definitely possible to limit the response size you are willing to recieve ... but why make the remote server send you any data that you don't acctually want? All you want is the headers, so use a "HEAD" request and ask for only the headers.)
|