determining 404

Dave Cragg dcragg at lacscentre.co.uk
Mon Apr 26 15:40:49 EDT 2004


At 9:43 am -0700 26/4/04, Richard Gaskin wrote:
>When obtaining a web resource, if it's 404 the server will usually
>return a page noting that for the user.  That's all well and good,
>but the 404 pages I've seen appear to be designed for human reading,
>and do not appear to have any consistent elements which would allow
>a machine to identify that the resource was not found.
>
>Is there something in the header that identifies that?
>
>How can I know when a requested URL doesn't exist?

I'm not sure if this is exactly what you want, but if you check the 
result after an http url call (get, post, etc.) it will contain the 
word "error" followed by the status code and the status message 
returned by the server (unless the call succeeded in which case the 
result will return empty.) Typically, for a 404 status code, the 
result will contain "error 404 File not found". You can't rely on the 
consistency of the message (it can vary by server, script, etc. and 
is intended to be human readable), but the status code will always be 
word 2 of the result.

Trivia 1: libUrl deems any http status code in the 200 range (i.e. 
200 - 299) to be successful and will return empty in the result.

Trivia 2: (for CGI script writers) If you want your rev CGI script to 
return a particular status code other than the default 200, add this 
line before the usual "Content-Type:  ..... " header line:

    put "Status: 404 Well I can't find it" & cr
    put "Content-Type: text/plain" & cr
    etc., etc.

Cheers
Dave


More information about the use-livecode mailing list