MIME types
MIME types (content types) tell the browser what to do with content sent to it.
Common MIME types
MIME Type | Result |
---|---|
application/octet-stream | Download |
text/plain | Display as plain text |
text/html | Render as HTML |
Results of sending as the wrong type
Sending the wrong MIME type can result in a file being downloaded instead of displayed, displayed instead of downloaded, or displayed improperly. You can see what MIME type your server is sending by using "Tools -> Page Info" in Firefox ("View -> Page Info" in Mozilla Suite) or you can use the Live HTTP Headers extension. Internet Explorer uses non-standard and insecure "sniffing" to sometimes override what the server tells it, so the oversight is not always apparent at first.
Configuring MIME types
Server-side scripts
If you are using a server-side scripting language to generate content, the appropriate content-type response header must be sent as well as the content itself. How this is accomplished depends on what language is being used. The following is an example using Perl:
print "Content-Type: text/html; charset=utf-8\n\n"; print "<html>\n"; print "<head>\n"; print "<title>Hello World!</title>\n"; print "</head>\n"; print "<body>\n"; print "<p>Hello World!</p>\n"; print "</body>\n"; print "</html>\n";
The first line of the above Perl script will identify the content as text/html and the browser will render it as such. Refer to the documentation of your scripting language for information about sending the appropriate content-type.