http-statuscode: Is picture available?


I made a Xojo WebApp and want to show Pictures from my normal homepage.

Before I show the image, I want to test, if is available.

I thought I can use something like this:

dim imageIsThere as string
dim socketImage as new HTTPSocket
imageIsThere = socketImage.Get("", 20)

if socketImage.HTTPStatusCode = 200 then 
   ImageView_Article1.URL = ""
  ImageView_Article1.URL = ""
end if

Pressing start in Xojo 2017.1 at macOS 10.12: everything is ok. The test.jpg is found, I got the status 200, and the picture is showing.

But when I copy it to my Windows 2012 as a compiled standalone app, the httpsocket doesn’t get the 200. I got a 0! The status 0 isn’t normal in http.

So what do I wrong?

Status 0 is a timeout. No connection or nothing was returned in the 20 seconds you specified.

Hmm. Ok.

Is my code OK? When yes: why does it work at my mac?

[quote=331332:@Ralf Kirsch]Hmm. Ok.

Is my code OK? When yes: why does it work at my mac?[/quote]
The code looks fine. My guess is that the dns lookup is taking longer on Windows.

Are you able to reach the image URL in a browser?

I had a similar issue a while back where an HTTPSocket would reach a webservice on OSX, but the same code would not work on a PC on the same network.

The solution that worked for me was to use an HTTPSecureSocket and the Secure property to false.
I have no idea why it solved the problem since the service’s protocol was http, not https.

Might be worth a shot though.