PerMalmberg / Smooth

C++ framework for embedded programming on top of Espressif's ESP-IDF.
Apache License 2.0
325 stars 30 forks source link

style sheet of webpage not respected #139

Closed squonk11 closed 3 years ago

squonk11 commented 3 years ago

Currently I am encountering a very strange issue: I copied a sample website from SelfHTML which I copied to my HTTPServer web_root. The page uses just some style sheets from a file in the subdirectory /css. But the resulting page I see in the browser does obviously not use the style sheet. I did the following tests:

Now I am somehow lost. Why the heck the webpage works perfectly when being loaded from harddisk and does not show up correctly when being loaded from the webserver? Do you have any idea what else I could check? Maybe there is a header information missing in the reply?

Edit: Now I tested the following: I copied the style sheet information into the index.html (between the tags). Then the page works perfectly. No idea why.

Edit2: Now I copied the webpage to my Webserver on my NAS which is an nginx webserver. Here it works. I compared the headers of the reply to the request for style.css. I see that nginx is replying with the header Content-Type: text/css while the HTTPServer of Smooth replies with the header content-type: application/octet-stream. I think this is the problem. Do you have an idea how I can fix this?

PerMalmberg commented 3 years ago

This function needs some expansion:

https://github.com/PerMalmberg/Smooth/blob/0e277276623a89b7484c8d9205776436ca947502/lib/smooth/application/network/http/http_utils.cpp#L87

squonk11 commented 3 years ago

ah, yes. I probably would have found it myself but I had to follow other tasks yesterday after my 2nd edit. So, I think it might make sense to add some more mime types. A maybe complete list can be found here: mime-types. But implementing all in Smooth would probably be too much. So an extract of the most frequent ones which might possibly be used in combination with an ESP32 application would be meaningful. If you don't mind I could select some and add them to a PR.

PerMalmberg commented 3 years ago

If you don't mind I could select some and add them to a PR.

No, of course not. Please do.

squonk11 commented 3 years ago

Currently I am again quite busy. I hope I will be able to do it during the weekend. Additionally there is again a compilation issue due to an old style cast using the latest master branch. Probably again a #pragma GCC diagnostic push is needed. Maybe I can find a fix for this too.

PerMalmberg commented 3 years ago

I'll close this as the PR is in progress.