sniff
v0.0.0-20180504072447-bdcd46c54acf
github.com/badu/http/sniff
Documentation
pkg.go.dev ↗Constants
Len
const Len = 512
The algorithm uses at most sniffLen bytes to make its decision.
Functions
DetectContentType
func DetectContentType(data []byte) string
DetectContentType implements the algorithm described at http://mimesniff.spec.whatwg.org/ to determine the Content-Type of the given data. It considers at most the first 512 bytes of data. DetectContentType always returns a valid MIME type: if it cannot determine a more specific one, it returns "application/octet-stream".