I think this needs to be split up:
If you are a server and wish to inform clients about alternative representations of the requested resource, you can do so via the Link
header as described in RFC 5988. A possible response could look like this:
HTTP/1.1 200 Ok
Content-Type: image/svg+xml
Link: <https://example.com/resource>; rel="alternate"; type="image/png"
Link: <https://example.com/resource>; rel="alternate"; type="image/jpeg"
If a client fetches a resource and wants to know which alternative representations are available, this were the way to go if no Link
headers can be found:
Fetch the resource and send an
Accept
header containing*/*
, implying every imaginable media type were understood by the client.Extract the media type from the response and add it to your Accept header with a weight
q=0
, letting the server know the served media type were not acceptable. Example:Accept: image/svg+xml;q=0, */*
Send out a new request for the same resource with the new accept header created in step 2
If you receive a
406/Not acceptable
response, you're done. If not: Go back to step 2.
You should now know all media types for the given resource on the server.