7.5. Customizing the Type Checking Phase
Following the successful completion of the access control and authentication steps (if configured), Apache tries to determine the MIME type (e.g., image/gif ) and encoding type (e.g., x-gzip ) of the requested document. The types and encodings are usually determined by filename extensions. (The term "suffix" is used interchangeably with "extension" in the Apache source code and documentation.) Table 7.1 lists a few common examples.
| MIME types | |
|---|---|
| extension | type |
| .txt | text/plain |
| .html, .htm | text/html |
| .gif | image/gif |
| .jpg, .jpeg | image/jpeg |
| .mpeg, .mpg | video/mpeg |
| application/pdf | |
| Encodings | |
| extension | encoding |
| .gz | x-gzip |
| .Z | x-compress |
By default, Apache's type checking phase is handled by the standard mod_mime module, which combines the information stored in the server's conf/mime.types file with AddType and AddEncoding directives to map file extensions onto MIME types and encodings.
The contents of the request record's content_type field are used to set the default outgoing Content-Type header, which the client uses to decide how to render the document. However, as we've seen, content handlers can, and often do, change the content type during the later response phase.
In addition to its responsibility for choosing MIME and encoding types for the requested document, the type checking phase handler also performs the crucial task of selecting the content handler for the document. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access