[][src]Function mimesniff::detect_content_type

pub fn detect_content_type(data: &[u8]) -> Mime

detect_content_type implements the algorithm described at https://mimesniff.spec.whatwg.org/ to determine the Content-Type of the given data. It considers at most the first 512 bytes of data. detect_content_type always returns a valid MIME type: if it cannot determine a more specific one, it returns "application/octet-stream". It currently supports only JPEG and PNG.