HTTP 406 status code means a server can’t return the requested version of the resource.
Clients can ask servers to serve a particular version of the resource (e.g. HTML document, image file, JSON object).
For example, imagine a user has a Spanish locale set as a default (
es-ES). A browser can (and will) ask a server to provide a Spanish version of the website, if possible, but otherwise fall back to an English version.
Accept-Language: es-ES, es;q=1, en;q=0.5
This process is called content negotiation. Apart from a language, clients can negotiate:
- Content types (MIME) via the
Acceptheader. An image file can be encoded as a JPEG or WebP, an API response can be returned as a JSON or XML.
- Encodings (think compression algorithms) via the
Accept-Encodingheader. The most common ones are gzip and brotli.
- Charsets via the
Accept-Charsetheader. Since UTF-8 support is ubiquitous, there’s little need to the point where most modern browsers don’t support it. Browsers omit this header to reduce entropy and preserve users’ privacy.
- Client hints via the
Accept-CHheader. Client hints is a content negotiation mechanism where clients can proactively inform browsers about supported features. This is an experimental header.
HTTP spec states that browsers can respond with
406 Not Acceptable when
the server is unwilling to supply a default representation. However, in reality, most servers do fall back to the default representation.
No spyware, no promotional emails, or keyword-stuffed junk. I will only send you a single email when I've got something interesting to say. Unsubscribe anytime.
You can also subscribe to the Atom feed (it's like RSS, but better).