Content negotiation with HTTP headers
The second method of content negotiation uses two HTTP headers on the HTTP request:
Accept-Profile
, which is used to signal the profiles accepted by the client.Accept
, which is used to signal the media types accepted by the client.
The Accept-Profile
HTTP header
This header contains one or more comma separated profiles. Optionally any of the profiles can be provided with a q
(for quality) parameter, indicating the desirability of the profile. If no q
parameter is provided for a profile, it is considered to have q=1.0
. The wildcard character *
matches any profile available.
Examples of valid Accept-Profile
headers are:
# Accept any profile
Accept-Profile: *
# Accept only Schema.org
Accept-Profile: <http://schema.org/>
# Prefer Schema.org, but accept Linked Art
# if Schema.org is not available.
Accept-Profile: <http://schema.org/>, <https://linked.art/ns/terms/>
# Prefer Schema.org, but accept any other profile
# if Schema.org is not available.
Accept-Profile: <http://schema.org/>, *
# Prefer Schema.org, but accept Linked Art
# if Schema.org is not available.
Accept-Profile: <https://linked.art/ns/terms/>; q=0.5, <http://schema.org/>; q=1.0
Additionally, if a token is availabe for the accepted profile, it can be used instead of the full url. In that case, the angle brackets (<>
)are left out:
# Accept only Schema.org
Accept-Profile: schema
# Prefer Schema.org, but accept Linked Art if
# if Schema.org is not available.
Accept-Profile: la; q=0.5, schema; q=1.0
The Accept
HTTP header
This header contains one or more comma separated media types. Optionally any of the media types can be provided with a q
(for quality) parameter, indicating the desirability of the media types. If no q
parameter is provided for a media types, it is considered to have q=1.0
. The wildcard character *
can be used for either the subtype or both the main and subtype of any of the media types.
Examples of valid Accept
headers are:
# Accept any media type
Accept: */*
# Accept any media type that has main type 'text'
Accept: text/*
# Accept only Turtle
Accept: text/turtle
# Prefer Turtle, but accept RDF/XML
# if Turtle is not available.
Accept: text/turtle, application/rdf+xml
# Prefer Turtle, but accept any other media type
# if Turtle is not available.
Accept: text/turtle, */*
# Prefer Turtle, but accept RDF/XML
# if Turtle is not available.
Accept: application/rdf+xml; q=0.5, text/turtle; q=1.0