mchttpd LiveCode server do not load images

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
capellan
Posts: 631
Joined: Wed Aug 15, 2007 11:09 pm
Contact:

mchttpd LiveCode server do not load images

Post by capellan » Mon Oct 15, 2018 4:16 am

Hi All,

Take a look at this screenshot. It shows the same webpage
loaded from mchttpd and opened directly in the browser:
mchttpd01.jpg
screenshot
Test this by yourself. Download the stack from:
http://fourthworld.net/lc/mchttpd-4W.zip

Open the stack, click start server and load this webpage
in the browser: http://127.0.0.1:8080/index.html

Why loading this webpage using mchttpd does not show
all images?

Now load the same index.html directly from hard disk,
(not using mchttpd) and the internet browser show all
images correctly.

Notice that when I load an image directly, through mchttpd
the browser shows the binary data of the image as text.
for example: http://127.0.0.1:8080/index.png
mchttpd02.png
screenshot of image as text
Just in case that it was a problem of mime types, I changed
every instance of "text/html" to "image/png" and it does
not shows the image anyway.

Which changes requires the script of mchttpd to load
in the browser all png or jpg as images instead of text?

Al

capellan
Posts: 631
Joined: Wed Aug 15, 2007 11:09 pm
Contact:

Re: mchttpd LiveCode server do not load images

Post by capellan » Tue Oct 16, 2018 3:21 am

After reading many webpages, I found the answer:
replace "file" with "binfile" in this script:

Code: Select all

 if the platform is "MacOS" then 
 put "binfile:" & oDir  & "/html/" & pFile into xFile
    else put "file:"& oDir  & "/html/" & pFile into xFile
This is the script change that works and load all images:

Code: Select all

 if the platform is "MacOS" then   put "binfile:" & oDir  & "/html/" & pFile into xFile
    else put "binfile:"& oDir  & "/html/" & pFile into xFile
Of course, if mchttpd works fine in Linux with "binfile" instead of "file"
(still have not tested this change in Linux) then delete the if structure
and put only this line:

Code: Select all

put "binfile:"& oDir  & "/html/" & pFile into xFile
Al

bogs
Posts: 4790
Joined: Sat Feb 25, 2017 10:45 pm

Re: mchttpd LiveCode server do not load images

Post by bogs » Tue Oct 16, 2018 11:07 am

Interesting find Al.
Image

capellan
Posts: 631
Joined: Wed Aug 15, 2007 11:09 pm
Contact:

Re: mchttpd LiveCode server do not load images

Post by capellan » Tue Oct 16, 2018 10:51 pm

I suspect that modern browser behave different that
early internet browsers for security reasons and that
explain why images are not loaded automatically.

In our present day internet, if you want to open
any kind of image inside the browser, the server
or maybe the browser itself creates a a minimal
html wrapper, like this:

Code: Select all

<html>
<head></head>
<body>
<img max-width=100% height="auto" src="http://127.0.0.1:8080/myimage.png"></img>
</body>
</html>
Look the list of vulnerabilities created
by files that are misidentified:

https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=mime

After i finish some pending work, maybe I could resume my previous
work in a Livecode based wikipedia reader. Maybe...

Al

Post Reply

Return to “Internet”