net.http.mime #
FILE AUTOGENERATED BY build.vsh - DO NOT MANUALLY EDIT
The MIME type database and a CHD perfect hash over 1248 file extensions, as constant data; the code using it is in lookup.v and mime.v.
fn exists #
fn exists(mt string) bool
returns true if the given MIME type exists
fn get_complete_mime_type #
fn get_complete_mime_type(mt string) MimeType
get_complete_mime_type returns a MimeType for the given MIME type.
fn get_content_type #
fn get_content_type(mt string) string
returns a content-type header ready to use for the given MIME type
fn get_default_ext #
fn get_default_ext(mt string) string
returns the default extension for the given MIME type
fn get_mime_type #
fn get_mime_type(ext string) string
returns the MIME type for the given file extension
fn lookup #
fn lookup(ext string) string
lookup returns the MIME type for the given file extension, or '' when unknown. The extension may be given with or without a leading dot, and is compared ASCII case-insensitively without allocating.
The extension is hashed and compared as up to three 8-byte windows, ASCII-case-folded branchlessly, so the cost does not grow with its length. After the single table probe the finish is branchless, so unknown extensions take no mispredicted early exits.
struct MimeType #
struct MimeType {
source string
extensions []string
compressible bool
charset string
}