Have you tried doing a HEAD request?
 
 
IIRC, this should return a CONTENT_LENGTH value
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of [EMAIL PROTECTED]
Sent: Thursday, October 30, 2003 5:38 PM
To: [EMAIL PROTECTED]
Subject: How to find the length of a pdf file on the internet

I have written a small spider which checks a database of webpage addresses for validity.
 
It returns the length of a web-page in bytes (supposedly), but I cannot get it to return the correct length of a PDF file web address
 
Code is basically:
 
    local ($PageToFetch, $httpname);
 
 
    # Use LWP module to communicate with the web page
 
    $ua = LWP::UserAgent->new;
    $ua->agent("MyApp/0.1 ");  # Create a request
 
    my $req = HTTP::Request->new(POST => "$PageToFetch",$ContentLen);
 
    $Filel1=$ContentLenub->document_length;
 
    $req->content_type('x-www-form-urlencoded');
 
    $req->content('match=www&errors=0');  # Pass request to the user agent and get a response back
    my $res = $ua->request($req);  # Check the outcome of the response
 
    $PageCheck=0;
    $CheckReason="";
    if ($res->is_success)
    {
        # Page address is valid
        $ValidName=1;
        $buffer=$res->content;
        $Filelen=length ($buffer);  # Store filelength - will not grab a pdf file !!
    }
How do I get the length of a pdf file into $Filelen ??
 
 
--
Rich Mellor
RWAP Services
35 Chantry Croft, Kinsley, Pontefract, West Yorkshire, WF9 5JH
TEL: 01977 610509
Visit our website at:
URL:http://www.rwapsoftware.co.uk

In need of adventure?
URL: http://www.rwapadventures.com


Stuck with ordinary dial up internet connection ??

Read our review of internet accelerators and broadband at:
URL:http://www.rwapservices.co.uk

Reply via email to