4 min read
2026-01-16
Without the Content-Type header, the browser may misinterpret the contents of the file.
For text types, specify the encoding: `text/html; charset=utf-8`.
The `X-Content-Type-Options: nosniff` header prevents MIME sniffing - an attack through content type substitution.
When uploading files through forms, use `multipart/form-data` and handle each part separately.
Compress text types (HTML, CSS, JS, JSON, SVG), but do not touch already compressed ones (PNG, JPEG, MP4).
`application/json` - for JSON API
`application/xml` - for XML API
`application/octet-stream` - for binary data
Don't just rely on the file extension - check the MIME type and content (magic bytes).
See also: HTTP status codes, JSON Formatter, XML Formatter