AJAX - The Complete Reference

(avery) #1

606 Part IV: Appendixes


For more information on registered MIME types, see http://www.iana.org/assignments/
media-types. However, be aware that many MIME types are invented and not registered. In
fact, some content types have numerous MIME types used in practice, and there is a large
amount of confusion and contention about appropriate MIME type usage, even for
something as common as XHTML.
When a Web server delivers a file, the header information is intercepted by the browser
and questioned. The MIME type, as mentioned earlier, is specified by the Content-Type
HTTP header. For example, if a browser receives a basic HTML file, the text/html value in
the Content-Type header indicates what the browser should do. In most cases, this results
in the browser rendering the file in the browser window. To determine what to do with a
particular MIME type that has been sent, the browser consults a look-up table mapping
MIME types to actions. A few browsers make this mapping clear as shown next, but most
do not.

In this particular example we see that Opera clearly indicates that when the browser
receives a data stream stamped with the MIME type application/x-shockwave-flash
or opens a local file with the .swf extension, it will pass it to the Shockwave Flash plug-in.
The MIME type is the key to why a file with an extension such as .php, .aspx, .jsp,
and so on is treated as XHTML by a Web browser when delivered over a network, but if it’s
opened from a local disk drive, it is not read properly. These extensions are often associated
with dynamically generated pages that are stamped with the HTML MIME type by a server-
side program, implicitly by the server-side framework used or as the result of consulting a
look-up table on the Web server that maps server-side file extensions to an outgoing MIME
type found in the Content-Type header.
Free download pdf