How would I go about doing a check whether HTTP link is returning an image file or a 404 page?
I'm worried that not all servers report 404 the same way, so a faulty image link would return a whole 404 page with HTML and etc.
THe HTTP links are intended to point only to an image files recognizable by Livecode.
Any help would be appriciated.....Thank you livecoders.
Check if "the URL" returns an image file?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Check if "the URL" returns an image file?
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com
Re: Check if "the URL" returns an image file?
404 pages contain <html></html> an image wouldn't.
But more: .png have PNG in the first line of the data, jpg have JFIF and bmp's have BM. Not sure if those are constants.
Simon
But more: .png have PNG in the first line of the data, jpg have JFIF and bmp's have BM. Not sure if those are constants.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Check if "the URL" returns an image file?
It'd be worthwhile to check the libURLLastRHHeaders() function. A 404 is required to have a not found response at the start of the headers if I remember the specification correctly.
For example, my server returns the following on the first line, first 404 then "regular":
For example, my server returns the following on the first line, first 404 then "regular":
Code: Select all
HTTP/1.1 404 Not Found
Code: Select all
HTTP/1.1 200 OK
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Check if "the URL" returns an image file?
Between the both suggestions, I'll be able to make it work. Thank you! Will return to tag subject as solved.
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com
[solved] Re: Check if "the URL" returns an image file?
Works like a charm:
Code: Select all
read from file ImageURL for 1 line
put it into myfilechunk // check file headers
if it contains "jfif" then answer "JPEG"
else if it contains "exif" then answer "JPEG with exif"
else if it contains "BM" then answer "BMP"
else if it contains "PNG" then answer "PNG"
else if it contains "GIF" then answer "GIF"
else
end if
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com