Author Topic: The Web Pages are not correctly displayed with IE9  (Read 8396 times)

Offline BitCoder

  • Newbie
  • *
  • Posts: 7
    • View Profile
The Web Pages are not correctly displayed with IE9
« on: July 26, 2012, 02:39:02 PM »
Somewhere in march 2011 Microsoft released IE9. Since then all web pages will not displayed correctly, unless the compatibility mode will be turned on. After a bit of investigation I found out that the used CSS file will not be loaded from the browser. The following error message will be output in the developer mode of the IE9
SEC7113: Das CSS wurde aufgrund eines fehlerhaften MIME-Typs ignoriert. Style.css.
This leads me to the conclusion that the web server of the uTasker gives a wrong MIME Type back.
Am I right or is there a possibility of changing the code in a web page to overcome this problem? Otherwise a correction of the web server is needed. Is there already a fix available?

All other browsers that I use (Firefox and Chrome) do not have this problem. Even not in the newest version.

Regards
Tom

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: The Web Pages are not correctly displayed with IE9
« Reply #1 on: August 02, 2012, 10:15:20 PM »
Hi Tom

I suspect that IE9 is being very strict with the content type.

Originally the browsers accepted HTTP without having a header returned but this changed with CHROME which wouldn't accept any HTML when it wasn't served with a header, leading to the support for a minimum header when the define SUPPORT_CHROME is set.

Newer versions of IE however didn't display text files correctly (CR and LF would not be shown) and so it was found that extra content type needed to be added to the header - define HTTP_HEADER_CONTENT_INFO.

It sounds as though IE9 versions now won't interpret .css unless its content type is explicitly declared and I expect that the following could solve it:
In http.c:

static unsigned short fnGenerateHTTP_header(unsigned char *pucTCP_Message, HTTP *http_session, unsigned char *ptrPush, int iRepeat)

    uMemcpy(pucTCP_Message, cucHTTP_header, SIMPLE_HTTP_HEADER_LENGTH);  // copy the HTTP header to start of each file to be transferred
    if (PLAIN_TEXTCONTENT(http_session->ucMimeType)) {                   // check whether this type should be declared as plain text content
        uMemcpy((pucTCP_Message + (SIMPLE_HTTP_HEADER_LENGTH - 2)), cucHTTP_plain_text, TEXT_PLAIN_HTTP_HEADER_LENGTH);
        usHTTP_HeaderLength += (TEXT_PLAIN_HTTP_HEADER_LENGTH - 2);
    }


This is adding "Content-Type: text/plain\r\n\r\n" to the header when the file type is plain text (as opposed to html where white space will be ignored by the browser).
By adding
    else if (http_session->ucMimeType == MIME_CSS) {                   // check whether this type should be declared as css content
        uMemcpy((pucTCP_Message + (SIMPLE_HTTP_HEADER_LENGTH - 2)), cucHTTP_css, CSS_HTTP_HEADER_LENGTH);
        usHTTP_HeaderLength += (CSS_PLAIN_HTTP_HEADER_LENGTH - 2);
    }


where

    static const CHAR cucHTTP_css[] = "Content-Type: text/css\r\n\r\n";
    #define CSS_PLAIN_HTTP_HEADER_LENGTH    (sizeof(cucHTTP_css) - 1)


it would declare the css content type accordingly and presumably allow the css content to be correctly interpreted by the browser.

Regards

Mark

Offline kingston

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: The Web Pages are not correctly displayed with IE9
« Reply #2 on: August 07, 2012, 08:42:02 AM »
Hey,

I tried your code Mark and it looks like it works!
I was also able to fix my problem from here http://www.utasker.com/forum/index.php?topic=1735.0 with the same method.
So if anybody has the problem that css won't load or html just gets displayed as plain text this should help.

I just added your code and edited it for html :

Code: [Select]
  }else if (http_session->ucMimeType == MIME_CSS) {                   // ¿ check whether this type should be declared as css content
        uMemcpy((pucTCP_Message + (SIMPLE_HTTP_HEADER_LENGTH - 2)), cucHTTP_css, CSS_PLAIN_HTTP_HEADER_LENGTH);
        usHTTP_HeaderLength += (CSS_PLAIN_HTTP_HEADER_LENGTH - 2);
    }
    else if (http_session->ucMimeType == MIME_HTML) {                   // ¿ check whether this type should be declared as html content
        uMemcpy((pucTCP_Message + (SIMPLE_HTTP_HEADER_LENGTH - 2)), cucHTTP_html, HTML_PLAIN_HTTP_HEADER_LENGTH);
        usHTTP_HeaderLength += (HTML_PLAIN_HTTP_HEADER_LENGTH - 2);
    }

where

Code: [Select]
static const CHAR cucHTTP_html[] = "Content-Type: text/html\r\n\r\n";
    #define HTML_PLAIN_HTTP_HEADER_LENGTH    (sizeof(cucHTTP_html) - 1)
   
    static const CHAR cucHTTP_css[] = "Content-Type: text/css\r\n\r\n";
    #define CSS_PLAIN_HTTP_HEADER_LENGTH    (sizeof(cucHTTP_css) - 1)

There was a "PLAIN" missing in your example but I guess this wasn't hard to spot for anyone :)

Thank you so much and sorry for taking over this thread...


Paul

 

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: The Web Pages are not correctly displayed with IE9
« Reply #3 on: August 07, 2012, 01:33:10 PM »
Hi Paul

Good to hear that the extra information in the HTTP header helps out.

It looks as though it may be interesting to add a table of types which are inserted in the string (to save a bit of text space) depending on the MIME type being served - then newer browser versions should never have any reason to start playing up...

Regards

Mark

Offline BitCoder

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: The Web Pages are not correctly displayed with IE9
« Reply #4 on: August 24, 2012, 08:00:31 AM »
Hi Mark and Paul
It took a while that I could verify your suggestions. First I tried it with my web pages and the simulator V1.4.11. Everything works correct. So I have to implement the fix on uTasker V1.3 SP5 and tried it on my target board and it works too. Yes, I still use this old version of uTasker for some reasons  ;)....(EtherNet/IP)

Thank for your help.

Tom
« Last Edit: August 24, 2012, 08:03:01 AM by BitCoder »