Content negotiation is basically a process of selecting the best representation from multiple representations that are available for a given response.
It simply allows one to choose rather than negotiate content that one wants to get in response. It is performed at the server-side. In simple words,
it chooses the best media type for matters to return a response to an incoming request.
There are two types of headers available for content negotiation:
- Content-Type: This header tells the server about the information that it will receive from the client.
- Accept: This header shows the data format requested by the client from the server.
We know that there are three pillars of the internet, they are:
- The resource
- The URL
- The representation
The formal definition of Content Negotiation is “the process of selecting the best representation for a given response when there are multiple representations available”.
By checking the “Accept” header, the Web API understands which representation the client is able to accept. For example, if we specify that the client can understand the following representation: application/xml , application/json, text/javascript
No comments:
Post a Comment