Skip to main content
Module

x/type_is/mod.ts

Infer the content-type of a HTTP Header for Deno
Latest
import * as typeIs from "https://deno.land/x/type_is@1.0.3/mod.ts";

Variables

Normalize a mime type. If it's a shorthand, expand it to a valid mime type.

Functions

Check if a request's header has a request body. A request with a body must either have transfer-encoding or content-length headers set. http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3

Compare a value content-type with types. Each type can be an extension like html, a special shortcut like multipart or urlencoded, or a mime type.

Check if the incoming request's header contains the "Content-Type" header field, and it contains any of the give mime types. If there is no request body, null is returned. If there is no content type, false is returned. Otherwise, it returns the first type that matches.