<QUOTH>
--------------- MESSAGE metacard.v004.n123.6 ---------------

From: Sivakatirswami <[EMAIL PROTECTED]>
Subject: Re: URL Exists
Date: Fri, 29 Dec 2000 12:45:29 -1000
MIME-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
In-Reply-To: <[EMAIL PROTECTED]>

on 12/29/00 10:03 PM, [EMAIL PROTECTED] at
[EMAIL PROTECTED] wrote:

>> I tried:
>> exists  (URL "http://www.gurudeva.org/index.html")
>> but it doesn't work even if the file is on the web site.
>> ??Did I do something wrong?
> Try:
> if url "http://www.gurudeva.org/index.html" is empty then
>   answer "The page doesn't exist."
> end if

That doesn't work either. As it turns out earlier posts covered this. . .MC
http protocol downloads the whole file. . .no way to just read header or
anything like that. I ended up downloading the file, if it doesn't exist,
you can test for 404 from the server.

    put URL tLastYear into oneYearAgo
    if oneYearAgo  contains "404 Not Found" then
       put "There was no page posted this day last year." into lastYearLink
    else
       buildLink 
    end if

Fortunately the app seeks only to check on the existence of very small html
files. Caveat of course is that the server might send some other message and
the test would be "wrong". And obviously this would not work efficiently for
testing the existence of a large .mov or .mpg file that might be several
megabytes in size. . .i.e. if the file exists you would download the entire
thing. . .
  The other route would be to open a socket, use FTP and test from  the
directory. . .but that's more complicated.

Sivakatirswami
Editor's Assistant/Production Manager
www.HinduismToday.com
www.HimalayanAcademy.com
[EMAIL PROTECTED]

</QUOTH>

Close but no cigar; you must not assume that a machine set up to do web serving
is also set up to do ftp servering. Nor should you assume than the FTP and HTTP
ports on the SAME IPADDY even point to the same machine the router may redirect
them using basic port forwarding. Even if neither of the above hold true, the
base directories may be different. 

you want to open an HTTP socket send the GET command, read until the
<CR><LF><CR><LF> [end of header] then just close off the socket. Evaluate the
header is it a '200' a '403' a '404' result code?

the actual code to do this is being left as an exercise unto the reader.

use tcpdump to catch the web client in the act, use that as a model. If you find
HEX hard to read and your tcpdump cant do ascii there is a nifty utility on
http://www.bestweb.net./~muaddib that might help you. Perl 5 is recomended.

this should help you detect the status and size of an http served document
without downloading a DVD image via a 1200 baud modem.

Bonne Chance

robin-david hammond
lead systems engineer
KPL
25-8D Van Zant
Norwalk CONN
USA



Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to