Scroll to navigation

Ns_Mime(3aolserver) AOLserver Library Procedures Ns_Mime(3aolserver)


NAME

Ns_GetMimeType - Return the MIME type of a file

SYNOPSIS

#include "ns.h"

char *
Ns_GetMimeType(char *file)

DESCRIPTION

Ns_GetMimeType(file)

The Ns_GetMimeType function uses the extension of file and looks up the associated MIME type stored internally in the server. Case is ignored. The return value is of the form "text/html".

AOLserver has a set of predefined file extension to MIME type associations. You can add to these associations by defining file extension to MIME type associations in the server configuration file in the ns/mimetypes section. If you define a file extension that already exists in the server, that file extension and MIME type association will be replaced with yours.

If no MIME type association exists for a particular file extension, or there is no file extension, the default and noextension MIME types are returned, respectively. These default to "*/*" but can be set in the server configuration file.

Here is an example ns/mimetypes section from the server configuration file:

ns_section "ns/mimetypes"
ns_param   ".doc"          "application/msword"
ns_param   ".ppt"          "application/vnd.ms-powerpoint"
ns_param   ".xls"          "application/vnd.ms-excel"
ns_param   ".cab"          "application/mscabinet"
ns_param   ".frl"          "application/x-perfpro"
ns_param   ".max"          "application/vviewer"
ns_param   ".mif"          "application/x-mif"
ns_param   ".frz"          "application/x-dffill"
ns_param   ".asvg"         "image/svg-xml"
ns_param   ".asvgz"        "image/svg-xml"
ns_param   ".svg"          "image/svg-xml"
ns_param   ".svgz"         "image/svg-xml"
ns_param   default         "*/*"
ns_param   noextension     "*/*"

SEE ALSO

nsd(1), info(n)

KEYWORDS

4.0 AOLserver