WWW returns wrong image but no error

I’ve successfully loaded an image from a website using WWW, but I found an odd problem if I request a file that doesn’t exist. If the requested file is similar to an existing file my web hoster sends a page offering “Multiple Choices” and a list of files that are close to the requested filename. So if I request “Image02.png” it suggests “Image00.png” or “Image01.png”.

The problem however is that I cannot detect this from the return values from WWW. It doesn’t return an error as I guess it gets a valid response, and the image is filled with the red ? and so you still get an image. Is there any way to find this case where the correct image is not found? Is there a way to detect that the returned image is the “red ?” ?

Server side, I have tried adding a .htaccess file with “Options -MultiViews” which seemed to be a way to stop the server returning such pages, but this didn’t work either (am on an Apache 1and1 server). I would prefer a more robust Unity side solution but at this stage I’d take any suggestion.

Thanks

This may not perfectly address your question, but the WWW class doesn’t have any real support for checking header information. You could try checking www.text to see if you get any relevant information there when it fails -if your site is delivering a web page there should be something there, and even when you’re downloading an image you can get header information about the image through www.text. You can also check www.size to see if there’s a noticeable difference between a valid image and an invalid one. Additionally, there are some third-part projects to bring more traditional socketed connections to Unity - UnityWeb springs to mind (Entity Crisis: UnityWeb - A WWW Alternative.), so if your web server is throwing back response headers something like that would be more likely to catch them.

When you say you get a ‘red’ image, is it an image with a red question mark? This is Unity’s default texture that it inserts when a texture is not found.