determining 404
Frank Leahy
frank at backtalk.com
Mon Apr 26 17:49:28 EDT 2004
On Apr 26, 2004, at 2:40 PM, use-revolution-request at lists.runrev.com
wrote:
> You can still check word 2 of the result and get the same
> information. When you do a "get url" and there is a 404 response, the
> html page (custom or otherwise) will be returned in the "it"
> variable, and the response code and message will be returned in "the
> result" following the word "error".
>
> So you can do something like this:
>
> get url "http://whatever.com/some.html"
> if the result is not empty then
> switch word 2 of the result
> case 404
> # whatever
> break
> case 403
> #whatever
> break
> default
> #whatever
> end switch
>
> else
> #do something with "it"
> end if
>
> Note that if you are using "load" instead of "get", and an error
> occurs such as a 404 response, to get the status code you should use
> libUrlErrorData(<url>). libUrlLastRHHeaders() won't be reliable in
> this case as another load request may have been processed by the time
> the one you are concerned with returns.
>
> See here for more info:
>
> <http://www.runrev.com/resources/liburl/
> liburldoc.shtml#libUrlErrorData>
>
> Cheers
> Dave
Dave,
It might be useful to add a libUrlGetResponseHeaders(<url>) function so
that one can get the headers regardless of whether an error occurred.
There are definitely times when it's useful to see the response headers
on successful requests (e.g. get server date/time, etc.)
-- Frank
More information about the use-livecode
mailing list