Connect HTTP fields to representations
Read HTTP fields as typed metadata and connect selected representations to media types and negotiation.
- fields
- representations
- content negotiation
A resource can have more than one representation
A resource is the target identified by a URI. A representation is information that reflects some state of that resource. The same resource can have HTML, JSON, language-specific, or content-coded representations selected for different requests.
Fields carry metadata about the message, selected representation, request conditions, caching, authentication, and many other concerns. Each registered field defines its own syntax and where its semantics apply.
GET /manual HTTP/1.1
Host: example.invalid
Accept: application/json
Accept-Language: en
Expected result: the request expresses preferences. The server can select a JSON English representation, choose another acceptable representation, or report that no acceptable representation is available according to its selection algorithm.
Content-Type identifies the media type
Content-Type states the media type of associated content. Clients should not
substitute a filename extension or assumed body shape for that declared metadata.
Some user agents apply additional sniffing rules, but sniffing is implementation
behavior and can create security or compatibility risks.
Content codings such as gzip are a separate transformation described by
Content-Encoding. The media type describes the representation after content
codings are decoded.
Negotiation selects; Vary communicates inputs
Proactive negotiation uses request fields such as Accept, Accept-Language, or
Accept-Encoding. When a response selection depends on request fields, Vary
names those inputs so caches can distinguish stored responses.
Vary is not a complete cache key definition and does not make a response
cacheable by itself. It changes matching behavior for a cache that stores the
response.
End-to-end does not mean immutable
Many representation fields are end-to-end: intermediaries forward them toward the recipient. An intermediary can still transform content when HTTP permits it and must then keep affected metadata consistent. Identify transformations and the responsible hop before assuming the origin sent the fields visible to the client.
