Check HTTP Status of an external URL


I’m looking for a way to call a certain URL by my Xojo Webapp to check the HTTP Status Code of the called URL. Is there a possibility?

Thanks for help
Cheers Mike

You can use an HTTPSocket to get the URL. Then check the HTTPStatusCode of that socket. It will return an integer of the status code.

Thanks for your help, Scott! I need to call a https:// Website, so could you please give me some more help to use the HTTPSecureSocket? I studied the language reference and don’t know the code to create the HTTPSecureSocket in my Webapp and the right syntax to call the SSL-URL. Can you give me some code?

just make a new HTTPSecureSocket object, call get method with URL and put some code in events, so you know when you get event if things worked or not.

As a test, I placed this code in a WebButton. When clicked, it would pop up a MsgBox with the status code.

dim mySocket as new HTTPSecureSocket dim s as string = mySocket.get("",0) MsgBox str(mySocket.HTTPStatusCode)

Technically you would better just do a HEAD request, so you don’t transfer all the content, just the status.
You can do so with CURL Plugin for example with OptionHeader=true.

Thank you all for your help!

Have a nice day, Mike