mimesniffer
mimesniffer copied to clipboard
JSON is not recognised
application/json
is widely used in REST APIs, but isn't detected by mimesniffer, nor by the default net/http sniffer.
This would be a useful addition for many people.
Correct sniffing should determine whether the content is valid JSON. If it isn't then the result would be "text/plain". This can be done using encoding/json
via the json.Valid function.
Workaround:
mimesniffer.Register("application/json", func(bs []byte) bool {
return json.Valid(bs)
})