how to detect re-directs using loadURL
Dave Cragg
dcragg at lacscentre.co.uk
Thu May 11 02:35:07 EDT 2006
On 11 May 2006, at 03:05, RGould8 at aol.com wrote:
> Can anyone tell me if it's possible to detect whether an URL is being
> re-directed, using load URL or some other command?
>
> I'd like to see if there's a way I can get the following status from a
> server when loading an URL, but I'm not sure how to retrieve it:
>
> 302 Success: Found Redirected to: (url)
> 200 Success: OK
> 301 Success: Moved Permanently
>
> Can anyone point me in the right direction?
There is a libUrlFollowHttpRedirects command. This seems to have been
omitted from the 2.6.1 docs. :-( You can get information here:
http://www.lacscentre.co.uk/liburl/
liburldoc.html#libUrlFollowHttpRedirects
If you set this to false, a "get url" call to such a url will return
the relevant response in "the result", like this:
error 302 found
You could then use the libUrlLastRHHeaders function to see the full
response from the server, for example if you needed to parse out the
"Location:" header, and handle the redirect yourself.
Cheers
Dave
More information about the use-livecode
mailing list