1 Module N_HTTP_MIME
gullradriel edited this page 2026-10-25 10:46:33 +01:00

HTTP MIME: media type from a file extension

Functions

Name
const char * n_http_mime_type(const char * path, size_t len)
media type for a path or file name, from its extension
int n_http_mime_table_check(void )
check that the built-in table is sorted, as its lookup requires

Functions Documentation

function n_http_mime_type

const char * n_http_mime_type(
    const char * path,
    size_t len
)

media type for a path or file name, from its extension

Parameters:

  • path the path or name (may be NULL only when len is 0)
  • len its length
  • path the path or name (may be NULL only when len is 0)
  • len its length

Return:

  • a static string, or NULL when the extension is unknown or absent
  • a static string, or NULL when the extension is unknown or absent

"/Games/a/index.HTML?x=1" gives "text/html". The extension is what follows the last '.' of the last segment ("/a.b/file" has none, nor do ".htaccess" and "file."). Text types are returned without a charset.

function n_http_mime_table_check

int n_http_mime_table_check(
    void 
)

check that the built-in table is sorted, as its lookup requires

Return: 1 when sorted, 0 otherwise (a library bug)