httpmedia-typehttp-accept-header

What does "+" means in HTTP Accept header?


How could I understand this record:

Accept: application/vnd.my.api+json

I mean, is this "+" symbol is standartized (anyway, I have not find it in spec), or it is just a convention?

Thanks.


Solution

  • The Accept header specifies a list of acceptable media types. The "+xxx" part of the media type is called suffix. It is an augmentation to the media type definition and helps to specify the underlying structure of that media type.

    RFC 6838, "4.2.8. Structured Syntax Name Suffixes" defines:

    XML in MIME [RFC3023] defined the first such augmentation to the
    media type definition to additionally specify the underlying
    structure of that media type. To quote:

      This document also standardizes a convention (using the suffix
      '+xml') for naming media types ... when those media types
      represent XML MIME (Multipurpose Internet Mail Extensions)
      entities.
    

    That is, it specified a suffix (in that case, "+xml") to be appended to the base subtype name.

    Since this was published, the de facto practice has arisen for using this suffix convention for other well-known structuring syntaxes. In particular, media types have been registered with suffixes such as "+der", "+fastinfoset", and "+json". This specification formalizes this practice and sets up a registry for structured type name suffixes.

    The primary guideline for whether a structured type name suffix is registrable is that it be described by a readily available
    description, preferably within a document published by an established standards-related organization, and for which there's a reference
    that can be used in a Normative References section of an RFC.

    Media types that make use of a named structured syntax SHOULD use the appropriate registered "+suffix" for that structured syntax when they are registered. By the same token, media types MUST NOT be given names incorporating suffixes for structured syntaxes they do not actually employ. "+suffix" constructs for as-yet unregistered structured syntaxes SHOULD NOT be used, given the possibility of conflicts with future suffix definitions.