- 5.1 The magnus.conf File
- 5.2 The server.xml File
- 5.3 The obj.conf File
- 5.4 The mime.types File
- 5.5 Trust Database Files (*.db Files)
- 5.6 The server.policy File
- 5.7 The certmap.conf File
- 5.8 The default.acl File
- 5.9 The default-web.xml File
- 5.10 The login.conf File
- 5.11 The keyfile File
- 5.12 Summary
- 5.13 Self-Paced Labs
5.4 The mime.types File
The Multipurpose Internet Mail Extensions (MIME) types file contains mappings between file extensions and MIME types. This file is utilized during request processing to tell the server what type of resource is being requested. It bases this information on the extension of the resource (such as .txt, .html, or .cgi) and associates a type, language, or encoding method based on the extension.
An initial MIME types file is created for each Web Server configuration; the name of the file is simply mime.types. You may create additional MIME types files and associate them to different virtual servers by using the <mime-file> element in the server.xml. Example 5.5 demonstrates the use of the <mime-file> element in the server.xml file.
Example 5.5. Virtual Server Definition for the MIME File
<virtual-server> <name>www.example.com</name> <http-listener-name>http-listener-1</http-listener-name> <host>www.example.com</host> <object-file>www.example.com-obj.conf</object-file> <mime-file>mymime.types</mime-file> <document-root>/export/home/example.com/public_html</document-root> <access-log> <file>/export/home/example.com/logs/access</file> </access-log> </virtual-server>
Associating different MIME files to each virtual server gives you the flexibility to support different resources at the virtual server level.
5.4.1 File Structure
The mime.types file contains a series of associations that helps the instance identity the request type and subsequently understand how to process the request. Example 5.6 demonstrates the MIME types file for the default Administration Node.
Example 5.6. Sample mime.types File
#--Sun Microsystems Inc. MIME Information # Do not delete the above line. It is used to identify the file type. # # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # type=application/octet-stream exts=bin type=application/astound exts=asd,asn type=application/fastman exts=lcc type=application/java-archive exts=jar type=application/java-serialized-object exts=ser type=application/java-vm exts=class type=application/mac-binhex40 exts=hqx type=application/x-stuffit exts=sit type=application/mbedlet exts=mbd type=application/msword exts=doc,dot,wiz,rtf type=application/oda exts=oda type=application/pdf exts=pdf type=application/postscript exts=ai,eps,ps type=application/studiom exts=smp type=application/timbuktu exts=tbt type=application/vnd.ms-excel exts=xls,xlw,xla, xlc,xlm,xlt type=application/vnd.ms-powerpoint exts=ppt,pps,pot [entries deleted] enc=x-gzip exts=gz enc=x-compress exts=z enc=x-uuencode exts=uu,uue type=magnus-internal/parsed-html exts=shtml type=magnus-internal/cgi exts=cgi,exe,bat type=application/x-x509-ca-cert exts=cacert type=application/x-x509-server-cert exts=scert type=application/x-x509-user-cert exts=ucert type=application/x-x509-email-cert exts=ecert type=application/vnd.sun.xml.writer exts=sxw type=application/vnd.sun.xml.writer.template exts=stw type=application/vnd.sun.xml.calc exts=sxc type=application/vnd.sun.xml.calc.template exts=stc type=application/vnd.sun.xml.draw exts=sxd type=application/vnd.sun.xml.draw.template exts=std type=application/vnd.sun.xml.impress exts=sxi type=application/vnd.sun.xml.impress.template exts=sti type=application/vnd.sun.xml.writer.global exts=sxg type=application/vnd.sun.xml.math exts=sxm type=application/vnd.stardivision.writer exts=sdw type=application/vnd.stardivision.writer-global exts=sgl type=application/vnd.stardivision.calc exts=sdc type=application/vnd.stardivision.draw exts=sda type=application/vnd.stardivision.impress exts=sdd type=application/vnd.stardivision.impress-packed exts=sdp type=application/vnd.stardivision.math exts=smf,sdf type=application/vnd.stardivision.chart exts=sds type=application/vnd.stardivision.mail exts=sdm
5.4.2 File Structure
The format is similar to the format of request/response information that is exchanged between a web browser and the Web Server to which it connects. This related format is specified as part of the Hypertext Transfer Protocol (HTTP) and has the following rules:
The first line in the MIME types file identifies the file format:
#--Sun Microsystems MIME Information
Other uncommented lines have the following format:
type=type/subtype exts=[file extensions]
where type/subtype refers to the MIME type and subtype and exts refers to the file extensions associated with this type. For example, the MIME types file uses the following mapping to associate the extensions .html and .htm to the type text/html:
The MIME types configuration file determines how your Web Server’s virtual server maps filename extensions to MIME types that are returned to the browser. Your browser then maps these MIME types to “helper” applications or in-line plug-ins.
The following subsections describe how MIME mappings are used on both the Web Server and the user agent during request/response processing.
18.104.22.168 Server Processing
When the Web Server receives a request for a resource from a client, it uses the MIME type mappings to determine what kind of resource is being requested.
During the ObjectType stage in the request handling process, the server determines the MIME type attribute of the resource requested by the client. Several different SAFs can be used to determine the MIME type, but the most commonly used one is type-by-extension. This function tells the server to look up the MIME type according to the requested resource’s file extension in the MIME types table (stored in the MIME types file).
MIME types are defined by three attributes: language (lang), encoding (enc), and content-type (type). At least one of these attributes must be present for each type. The most commonly used attribute is type. When the server sends the response to the client, the type, language, and encoding values are transmitted in the Content-Type headers of the response.
If there is more than one ObjectType directive, the server applies all the directives in the order in which they appear. However, after a directive sets an attribute of the MIME type, encoding, or language, further attempts to set the same attribute are ignored.
Figure 5.1 demonstrates a client making a request for a particular file and how the server uses the mime.types file to determine how to process that request.
Figure 5.1 MIME File Usage During Request Processing
The following steps indicate a high-level overview of how the server processes this request:
- A client makes a URL request of http://www.example.com/index.html.
- The server accepts the request and selects the appropriate virtual server (not shown).
- The server determines the name of the object configuration file, based on the virtual server’s object-file settings (not shown). This instructs the server on how to process the request (not shown).
- The server executes the request-response process, as dictated by the object configuration file.
- At the point when the server reaches the ObjectType stage, it reads the MIME types file and searches for an extension that matches the file requested (in this case it is an HTML file).
- The server finds a match and sets the type to text/html.
- The server selects the appropriate service to process the request (not shown).
- The server sends the response to the client with the appropriate Content-type set in the response header.
22.214.171.124 Client Processing
The SAF defined for the appropriate service stage generates the data and sends it back to the client that made the request. When the server sends the data to the client, it also sends headers. These headers include the MIME type attributes that are known (which are usually defined by type attributes).
The client maintains its own MIME types table, as shown in Figure 5.2.
Figure 5.2 Client MIME Definitions
When the client receives the header, it uses the information contained in its own MIME types table to determine what to do with the data. For browser clients, the usual action is to display the data in the browser window.
Sometimes the requested resource cannot be displayed in the browser window and needs to be handled by another application. In such cases, the Content-type sent back by the server typically starts with application/; for example, application/x-pdf (for .pdf file extensions) or application/x-maker (for .fm file extensions).
The client has its own set of user-editable mappings that tells the browser which application to use for certain data types. For example, if the type is application/x-pdf, the client usually handles it by opening the Adobe Acrobat Reader application to display the file.
The server.xml file contains definitions for each virtual server contained within the instance, so there is a one-to-many relationship between the server.xml file and virtual servers.
Each virtual server can use a different MIME types file for mapping associations. Therefore, there is a one-to-many relationship between an instance and the MIME types file(s), but there is a one-to-one relationship between the virtual server and its MIME types file.
Although the default MIME types file includes a definition of the most commonly known MIME types, you are free to modify the file to add support for any additional MIME types. To add a new MIME type definition, simply append the definition to the existing MIME types in the file in the following format (where type/subtype is the MIME type of the document whose filename ends with one of the extensions listed):
The extension list includes any number of comma-separated filename extensions. Examples of MIME type entries can be found in the default MIME types file included with your virtual server.
You can also use the Administration Console or the command line interface to update the MIME types file for the virtual server. After the file is updated, you must deploy the updated configuration before the changes are reflected on the appropriate Administration Node(s).
The MIME types file is read when the instance is started or when a dynamic reconfiguration is performed. The syntax contained in the MIME types file is validated within the start-up or reconfiguration code base. Errors found within the MIME types file or within the server.xml file (as it pertains to the <mime-file> attribute) may prevent the instance from starting.