Code Confidencebuild 3.0.0.201402161939

MIME types

The server has an internal table with all the recognized mime types. Each time a file or an internal resource is sent out by the server, its extension is searched in this table and if a match is found, the associated MIME type is then sent out in the header. The server already provides entries for the following standard file extensions: 'html', 'htm', 'gif', 'jpg', 'css', 'js', 'png' and the user is responsible for adding any further entry. The syntax for adding an entry is the following:

CYG_HTTPD_MIME_TABLE_ENTRY(entry_label, extension_string, mime_tipe_sting);

entry table      : an identifier unique to this entry
extension string : a string containing the extension for this entry
type_string      : the mime string. The strings for many more mime types 
                   is included in a file in the "doc" directory.

The following is an example of how to add the Adobe Portable Document Format pdf MIME type to the table:

CYG_HTTPD_MIME_TABLE_ENTRY(hal_pdf_entry, "pdf", "application/pdf");

MIME Types for Chunked Frames

For chunked frames, which are generally used inside c language callbacks, there is no file name to match an extension to, and thus the extension to be used must be passed in the cyg_httpd_start_chunked() call. The server will then scan the MIME table to find a MIME type to match the extension. For example, to start a chunked transfer of an html file, the following call is used:

cyg_httpd_start_chunked("html");

In any event, it is the responsibility of the user to make sure that a match to all used extensions is found in the table search. Failing this, the default MIME type specified in the CYGDAT_NET_ATHTTPD_DEFAULT_MIME_TYPE string is returned.