ufairiya / mongoose

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

Provide MIME type mapping to application through library API interface #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is indeed a feature request. 

Application who serves dynamic web pages needs to map from file extension
to mime type and specify it in response header. Currently the MIME type
information is managed inside the library but not exported through API
interface.

What is the expected output? What do you see instead?
Given a file extension, e.g. jpg, png, a library API function returns the
MIME type if it is found or NULL if not found.

What version of the product are you using? On what operating system?
2.4, Windows and Linux.

Please provide any additional information below.
"Mongoose can export function get_mime_type()."

Original issue reported on code.google.com by shidongc...@gmail.com on 10 Apr 2009 at 7:25

GoogleCodeExporter commented 9 years ago
I would need this as well. Ability s.a. 

        mg_add_header( conn, "Content-type", mime );    // no such thing

to provide the MIME type of content we're giving out. I'm using Mongoose as an 
embedded server (not serving 
any files from the disk at all, just programmatically tying to HTTP interface).

Original comment by akau...@gmail.com on 29 Apr 2010 at 10:19

GoogleCodeExporter commented 9 years ago
In embedded mode, what stops you from doing
   mg_printf(conn, "Content-Type: %s\r\n", "my-mime-type"); ?

Why do you need mg_add_header? mg_printf() can do it call. You are free to 
construct any headers you want.

Original comment by valenok on 29 Apr 2010 at 10:30

GoogleCodeExporter commented 9 years ago
Yes. I came to think of this just a bit after posting the message.

I've been working with frameworks that handled content and headers differently. 
That's why it took some time 
for me to realize Mongoose does not.

Original comment by akau...@gmail.com on 2 May 2010 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by valenok on 7 Sep 2010 at 7:38

GoogleCodeExporter commented 9 years ago
Consider the following issue:

for loop unknown length printed
totalLength += mg_printf(conn, "content");
totalLength += mg_printf(conn, "some more content");
end for loop

mg_add_header( conn, "Content-length", totalLength);    // no such thing

Original comment by josephjk...@gmail.com on 26 Jul 2012 at 6:10