2

As you know you can add multiple media types to the HTTP Accept header. When it comes to the question "What type should the server return?" most explanations and the spec as well seem to only explain the algorithm to select the "preferred" media type based on the specifity, quality and level of the media type.

But what should be done when they are all the same? Say I have

  • request 1) Accept: application/vnd.company.v3+json, application/vnd.company.v4+json
  • request 2) Accept: application/vnd.company.v4+json, application/vnd.company.v3+json

Is the order important? I found a blog post which states that, but couldn't find a source nor information about it in the spec.

Or is this undefined behaviour and it is up to the server to decide (e.g. always return the newest version) or return "300 Multiple Choice" (rarely seen in the wild) or something else.

Pipo
  • 5,623
  • 7
  • 36
  • 46

1 Answers1

3

The blog post is wrong; the ordering is not relevant. it's up to the server to choose, or, as you said, return 300.

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98
  • Thanks. That's what I thought. But do you know of this is explicitly written anywhere? – Pipo Nov 09 '17 at 12:17
  • The specification is RFC 7231 and it does not say that ordering is relevant. – Julian Reschke Nov 09 '17 at 15:39
  • Okay. So far I only saw this explicitly for `Accept-Language`: "Note that some recipients treat the order in which language tags are listed as an indication of descending priority, particularly for tags that are assigned equal quality values (no value is the same as q=1). However, this behavior cannot be relied upon." – Pipo Nov 10 '17 at 06:56