Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON is not recognised #3

Open
rickb777 opened this issue Mar 17, 2022 · 1 comment
Open

JSON is not recognised #3

rickb777 opened this issue Mar 17, 2022 · 1 comment

Comments

@rickb777
Copy link

rickb777 commented Mar 17, 2022

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.

@rickb777
Copy link
Author

Workaround:

mimesniffer.Register("application/json", func(bs []byte) bool {
    return json.Valid(bs)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant