Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In these cases the client can negotiate with the server to get the most suitable format. Of course, the server has the final say in what it will return. If the server is unable to return more than one format, or if the format being requested is not supported, then the server can choose to return a default format or simply respond with a 406 Not Acceptable status.

Negotiation is handled through one or more request header fields such as Accept, Accept-Charset, Accept-Encoding, and Accept-Language. The Accept header field pertains specifically to the media type being requested. A client would pass in the media type, or a special pattern to indicate options and preferences, and the server is expected to do its best to accommodate the request.

...

ValueMeaning
text/htmlClient is requesting that the resource only be returned as HTML.
image/*Client is requesting that the resource be returned as an image, but the sub-type (i.e., JPEG, PNG, etc.) is up to the server.
image/jpg, image/png; q=.8, */*Client is requesting that the resource be returned as a JPEG image, but if that is not available then return as a PNG image. If that is not available then return any format that the server determines.

If the values listed in the Accept field make it impossible for the server to accommodate, the server is expected to return a 406 Not Acceptable status. Therefore, clients might want to include a wildcard pattern (i.e., */*) in the value to ensure something is always returned.