<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="/lib/xsl/devedge-1.00/article_en.xsl"?>
<nde:article 
  url="/viewsource/2003/mime-types/" 
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:nde="http://devedge.netscape.com/2002/de" 
  xmlns:ent="http://devedge.netscape.com/2003/ent"
  xml:lang="en">
  <nde:header>
    <nde:title>
      Properly Configuring Server MIME Types
    </nde:title>

    <nde:category>
      Technote
    </nde:category>

    <nde:pubdate year="2003" month="02" day="20"/>
        <!-- 
    <nde:moddate year="1900" month="01" day="01"/>
        -->

    <nde:summary>
      MIME types are intended to be used to inform user agents
      about the media types of documents contained in email and on the web.
      Learn why properly configuring your web server and using
      a web browser such as Netscape 7.x which respects the 
      reported MIME type of media is important for the quality
      of experience of your visitors as well as their security.
    </nde:summary>
    
      <!-- 
    <nde:abstract>
    </nde:abstract>
      -->
    
    <nde:channels>
      <nde:channel id="viewsource"/>
    </nde:channels>
    
    <nde:keywords>
      solutionfinder,
      MIME, MIME Type, Content Type, Netscape 7, Netscape 6, Mozilla,
      Netscape Gecko, Gecko, Web Server Administration,
      HTML source, page displayed as source, page displayed as plain text
    </nde:keywords>
    
      <!-- 
    <nde:translations>
      <nde:trans url="http://ex.web/blah/" title="English translation of this article">English</nde:trans>
    </nde:translations>
      -->

      <!-- 
    <nde:alternates>
      <nde:alt url="http://blah.web/ex/" title="PDF version of this article">PDF</nde:alt>
    </nde:alternates>
      -->

    <nde:authlist>
      <nde:author>
        <nde:authname>Bob Clary</nde:authname>
        <nde:authaffil>Netscape Communications</nde:authaffil>
      </nde:author>
    </nde:authlist>
    
    <nde:translations>
      <nde:trans url="http://www.ltrebing.de/interests/web/devedge-mime-types/">Deutsch</nde:trans>
    </nde:translations>
    

  </nde:header>

    <!-- 
  <nde:head>
  </nde:head>
   -->

  <nde:content>

    <h2 id="Background">Background</h2>
    <p>
      By default, many web servers are configured to report a 
      MIME type of <code>text/plain</code> for unknown content types.  
      As new content types are invented or added to web servers,
      web administrators may fail to add the new MIME types to their web server's 
      configuration. This results in the new content being reported as having
      MIME type <code>text/plain</code>.
      This is a major source of problems for users of <a href="/central/gecko/">Netscape Gecko</a>-based 
      browsers such as Netscape 6.x, Netscape 7.x, CompuServe 7, AOL for Mac OS X
      as well as Mozilla, which respect the MIME types as reported by 
      web servers and web applications. 
    </p>

    <h2 id="mimedefn">What are MIME types?</h2>

    <p>
      <acronym title="Multipurpose Internet Mail Extensions">MIME</acronym> 
      types describe the media type of content either in email or served by web
      servers or web applications and are intended to help
      guide a web browser in how the content is to be processed and displayed. 
      Examples of MIME types are <code>text/html</code> for normal web pages, 
      <code>application/x-java-applet</code> for Java<ent:trade/> applets and <code>application/pdf</code>
      for Adobe<sup><ent:reg/></sup> PDF documents. 
    </p>

    <p>
      Web browsers announce to web servers which media types they are capable of
      processing (as well as preferences for specific types) while web servers respond
      to web browsers with the requested media and the media (or MIME) type 
      of the content which was returned. This negotiation between web browsers and
      web servers over the type of content to be served is critical to the architecture
      of the web. In fact, the HTTP specification requires that a web browser respect 
      the MIME type reported by a web server.
    </p>

    <h3>Technical Background</h3>
    <p>
      MIME is currently defined in RFCs 
      <a href="http://www.isi.edu/in-notes/rfc2045.txt">2045</a>,
      <a href="http://www.isi.edu/in-notes/rfc2046.txt">2046</a>,
      <a href="http://www.isi.edu/in-notes/rfc2047.txt">2047</a>,
      <a href="http://www.isi.edu/in-notes/rfc2048.txt">2048</a>, and
      <a href="http://www.isi.edu/in-notes/rfc2049.txt">2049</a>
      and registered values for MIME types are available in 
          <a href="http://www.iana.org/assignments/media-types/index.html">IANA 
        | MIME Media Types</a>.
      The <a href="http://www.w3.org/Protocols/HTTP/1.1/spec.html">HTTP specification</a>
      defines a superset of MIME which is used to describe the media types used on the web.
    </p>

    <h2 id="mimeimportant">Why are correct MIME types important?</h2>
    <p>
      <img src="incorrect-mime-screen.jpg" alt="Example site with text/plain MIME type for an HTML page" title="Example site with text/plain MIME type for an HTML page" style="height: 177px; width: 200px; float: left; padding: 0 .5em;"/>
      If the web server or application reports an incorrect MIME type
      for content, a web browser has no way, <em>according to the HTTP specification</em>,
      of knowing that the author actually intended the content to be 
      processed and displayed in a way different from that implied by the reported
      MIME type.
    </p>

    <p>
      Some other web browsers,
      such as Microsoft<sup><ent:reg/></sup> Internet Explorer,
      try to allow for misconfigured web servers and applications by
      <em><a href="http://support.microsoft.com/default.aspx?sd=msdn&amp;scid=kb;en-us;293336">guessing</a></em>
      what the correct MIME type should be. This has sheltered many web administrators
      from their own errors, since Internet Explorer will continue to process content
      as expected even though the web server is misconfigured, e.g. 
      displays an image which is reported to be plain text.
    </p>

    <h2 id="mimeguessing">Why browsers should not guess MIME types</h2>

    <p>
      Apart from violating the HTTP specification, it is a 
      bad strategy for browsers to guess MIME types for the following reasons:
    </p>

    <ol>
      <li>
        Loss of control
        <p>
          If the browser ignores the reported MIME type, web administrators and
          authors no longer have control over how their content is to be processed. 
        </p>
        <p>
          For example, a web site oriented for web developers might wish to send certain
          example HTML documents as either <code>text/html</code> or <code>text/plain</code> in order
          to have the documents either processed and displayed as HTML or as source code.
          If the browser guesses the MIME type, this option is no longer available to the
          author.
        </p>
      </li>
      <li>
        Security
        <p>
          Some content types, such as executable programs, are inherently unsafe. For this reason
          these MIME types are usually restricted in terms of what actions a web 
          browser will take when given content of that type. An executable program
          should not be executed on the user's computer and at most should cause a dialog
          to appear <strong>asking the user</strong> if they wish to download the file.
        </p>
        <p>
          MIME type guessing has led to security exploits in Internet Explorer 
          which were based upon a malicious author incorrectly reporting a MIME 
          type of a dangerous file as a safe type. This bypassed the normal download dialog
          resulting in Internet Explorer guessing that the content was an executable
          program and then running it on the user's computer.
        </p>
      </li>
    </ol>

    <h2 id="mimehowto">How to determine the correct MIME type for your content</h2>
    <p>
      There are several steps which you can take to determine the correct MIME type
      value to be used for your content.
    </p>

    <ol>
      <li>
        <p>
          If your content was created using a vendor's software application, read the
          vendor's documentation to see what MIME types should be reported for different
          media types.
        </p>
      </li>
      <li>
        <p>
          Look in the <a href="http://www.iana.org/assignments/media-types/index.html">IANA 
            | MIME Media Types</a> registry which contains all registered MIME types.
        </p>
      </li>
      <li>
        <p>
          If the media type is displayed using a plug-in in Netscape Gecko, install the plug-in
          and then look in the <code>Help->About Plug-ins</code> Menu to see what MIME types
          are associated with the media type.
        </p>
      </li>
    </ol>

  </nde:content>

  <nde:related area="nde">
    <nde:item url="/viewsource/2002/incorrect-mime-types/">Incorrect mime type for CSS files</nde:item>
  </nde:related>
  
  <nde:related area="ext">
    <nde:item url="http://www.iana.org/assignments/media-types/index.html">IANA 
      | MIME Media Types</nde:item>
    <nde:item url="http://www.w3.org/Protocols/HTTP/1.1/spec.html">Hypertext 
      Transfer Protocol -- HTTP/1.0</nde:item>
    <nde:item url="http://support.microsoft.com/default.aspx?sd=msdn&amp;scid=kb;en-us;293336">Microsoft - 
      293336 - INFO: WebCast: MIME Type Handling in Microsoft Internet Explorer</nde:item>
    <nde:item url="http://msdn.microsoft.com/workshop/networking/moniker/overview/appendix_a.asp">Microsoft - 
      Appendix A: MIME Type Detection in Internet Explorer</nde:item>
    <nde:item url="http://www.microsoft.com/windows/ie/downloads/critical/q290108/default.asp">Microsoft - 
      Security Update, March 29, 2001</nde:item>
    <nde:item url="http://www.microsoft.com/windows/ie/downloads/critical/Q313675/default.asp">Microsoft - 
      Security Update, December 13, 2001</nde:item>
  </nde:related>
  
</nde:article>
