Hoffimh / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

Content-type attribute is being ignored. #384

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. include the following inside function callback:
  ...
  if (event == MG_NEW_REQUEST)
    {
    char content[32]="<HTML>Hello World!</HTML>";
    int contentLength = strlen(content);

    mg_printf
      ( conn, 
        "HTTP/1.1 200 OK\r\nCache: no-cache\r\n" 
        "Content-Type: text/html\r\n"  // Defective specification.
        "Content-Length: %d\r\n\r\n%s",
        contentLength,content
      );

    return "";
    } // endif MG_NEW_REQUEST
  ...
2. Run it.

What is the expected output? What do you see instead?
"Hello world" should be printed on the screen as a webpage. But it prints the 
raw content of the response as it is. Instead of displaying the content of the 
response as an html webpage, it displays it as a text file -- html markup and 
all.

What version of the product are you using? On what operating system?
Mongoose 3.1 on Windows through IE9.

Please provide any additional information below.
Patch this by changing the following line:
   "Content-Type: text/html\r\n"        // Defective specification.
to this:
   "MIME-Type: text/html\r\n"           // Correct specification.

The source file 'mongoose.c' contains 3 or 4 places where the 'Content-type:' 
attribute is being used.  If we find that the patch only applies to IE9, then 
perhaps a *documentation* improvement would be in order.  Documenting this 
change by browser type by suggesting directives without actually cluttering 
mongoose.c with these directives might be the way to go.

Original issue reported on code.google.com by morningz...@yahoo.com on 10 Aug 2012 at 5:43

GoogleCodeExporter commented 8 years ago
The defective part in fact is IE9.
Please look at the HTTP specification, 
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
I cannot see anywhere the MIME-Type header you're mentioning.

Original comment by valenok on 10 Aug 2012 at 6:52

GoogleCodeExporter commented 8 years ago
Valenok,

You're absolutely right.  

In the past 3 days, I unearthed two more places in my *simple* application 
where IE9 did not comply.  Even if I were to submit documentation on getting a 
Mongoose app to cope with IE9, it would be outside the scope of your project.  
Since IE9's share of browser use has been declining, a suggestion on what 
browsers work best with Mongoose would be helpful to newbie's like me.  

Many will appreciate such a recommendation particularly if it were posted 
conspicuously on your site.

Thanks so much for developing this truly lightweight http server.

Original comment by morningz...@yahoo.com on 14 Aug 2012 at 7:54