Skip to content

Commit 3b356f4

Browse files
ethanresnickdgeb
authored andcommitted
Content Negotiation: clarify client & server obligations and consequences of violating them
See rationale in #673. Also consolidates all the rules into the content negotiation section.
1 parent 4c0cbe0 commit 3b356f4

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

format/index.md

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,31 @@ interpreted as described in RFC 2119
2828

2929
## Content Negotiation <a href="#content-negotiation" id="content-negotiation" class="headerlink"></a>
3030

31-
Clients **MUST** send all JSON API data in request documents with
32-
the header `Content-Type: application/vnd.api+json`.
31+
Clients **MUST** send all JSON API data in request documents with the header
32+
`Content-Type: application/vnd.api+json`, without any media type parameters.
3333

34-
Clients **MUST** ignore all parameters for the `application/vnd.api+json`
35-
media type received in the `Content-Type` header of response documents.
34+
If a client violates this requirement, servers **MUST** respond with a
35+
`415 Unsupported Media Type` status code.
36+
37+
Clients that include the JSON API media type in their `Accept` header, **MUST**
38+
specify the media type there at least once without any media type parameters.
39+
40+
If a client violates this requirement, and its `Accept` header doesn't contain
41+
any other media types that the server can produce, the server **MUST** respond
42+
with a `406 Not Acceptable` status code.
43+
44+
Servers **MUST** send all JSON API data in response documents with the header
45+
`Content-Type: application/vnd.api+json`, without any media type parameters.
3646

37-
Servers **MUST** send all JSON API data in response documents with
38-
the header `Content-Type: application/vnd.api+json`.
47+
Servers **MUST NOT** send responses with the `application/vnd.api+json` media
48+
type if the client has not indicated, using its `Accept` header, that it can
49+
understand this format.
3950

40-
Servers **MUST** return a `406 Not Acceptable` status code if the
41-
`application/vnd.api+json` media type is modified by the `ext` parameter in
42-
the `Accept` header of a request. Otherwise, servers **MUST** return a `415
43-
Unsupported Media Type` status code if the `application/vnd.api+json` media
44-
type is modified by the `ext` parameter in the `Content-Type` header of a
45-
request. Servers **MUST** ignore all other parameters for the
46-
`application/vnd.api+json` media type in `Accept` and `Content-Type`
47-
headers.
51+
Clients **MUST** ignore any parameters for the `application/vnd.api+json`
52+
media type received in the `Content-Type` header of response documents.
4853

49-
> Note: These requirements may allow future versions of this specification
50-
to support an extension mechanism based upon the `ext` media type parameter.
54+
> Note: These requirements exist to allow future versions of this specification
55+
to use media type parameters for extension negotiation and versioning.
5156

5257
## Document Structure <a href="#document-structure" id="document-structure" class="headerlink"></a>
5358

@@ -627,16 +632,6 @@ The following characters **MUST NOT** be used in member names:
627632
Data, including resources and relationships, can be fetched by sending a
628633
`GET` request to an endpoint.
629634

630-
Clients **MUST** indicate that they can accept the JSON API media type, per
631-
the semantics of the HTTP `Accept` header. If present, this header value **MUST**
632-
also include any media type extensions relevant to the request. Servers **MUST**
633-
return a `406 Not Acceptable` status code if this header specifies an
634-
unsupported media type.
635-
636-
> Note: Servers may support multiple media types at any endpoint. For example,
637-
a server may choose to support `text/html` in order to simplify viewing content
638-
via a web browser.
639-
640635
Responses can be further refined with the optional features described below.
641636

642637
### Fetching Resources <a href="#fetching-resources" id="fetching-resources" class="headerlink"></a>
@@ -1133,10 +1128,6 @@ strategies.
11331128
A server **MAY** allow resources of a given type to be created. It **MAY**
11341129
also allow existing resources to be modified or deleted.
11351130

1136-
Any requests that contain content **MUST** include a `Content-Type` header
1137-
whose value is `application/vnd.api+json`. This header value **MUST** also
1138-
include media type extensions relevant to the request.
1139-
11401131
A request **MUST** completely succeed or fail (in a single "transaction"). No
11411132
partial updates are allowed.
11421133

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy