tass-belgium / picotcp-modules

Application level modules to run on top of the popular Embedded picoTCP TCP/IP stack
GNU General Public License v2.0
8 stars 11 forks source link

PsiControl: PicoTCP webserver not setting MIME type #1

Closed BrechtN closed 9 years ago

BrechtN commented 10 years ago

Hi,

We have a problem with our picotcp webserver on our board. Client asked compatibility with Internet explorer. In IE8 everything looks fine. In IE9 the CSS doesn't load due to an error: “SEC7113: CSS was ignored due to mime type mismatch” In Firefox & Chrome, there is no problem.

The CSS file is a statically served file from flash. I can't find any mime type in the webserver code, so I suggest this is not set.

Kind regards, Brecht Neyrinck

picotcp ie8 picotcp ie9

maximevince commented 10 years ago

Microsoft says this: http://msdn.microsoft.com/en-us/library/ie/hh180764(v=vs.85).aspx Basically it says that you should indeed set the mime-type of the css file to: "text/css", in HTTP reply.

Looking at https://github.com/tass-belgium/picotcp-modules/blob/master/libhttp/pico_http_server.c, The easiest way is probably to implement a new type of "returnHeader", like the returnOkHeader, specifying a Content-type as well. In this case that would be "Content-type: text/css"

Better would be to create a function that could dynamically generate a header, taking some parameters, such as the Content-type, cache-ability, and maybe others among these: http://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields

Cheers

bavovanachte commented 9 years ago

Managed to reproduce by building the sandbox demo webserver on Linux and running the IE9 windows 7 virtual machine in virtualbox. (https://www.modern.ie/en-us)

bavovanachte commented 9 years ago

Fixed in 0e647453f0f5e2da8172579a32c7695ca7e5ddbe and 0ccce47304a9d92836702ff24a76c6985dc73177

Changes: setting the MIME-type can now happen in 2 possible ways, depending on the http respond method used. When pico_http_respond() is used, the HTTP module will try to deduce the MIME-type based on the name of the requested resource (the extension). When pico_http_respond_mimetype() is used, the MIME-type can be passed along as an extra parameter to the function. This is useful in special cases when the MIME-type cannot be deduced from the filename or some special (unsupported) MIME-type is to be used.

BrechtN commented 9 years ago

Bugfix validated, thanks!