To negotiate the representation of a resource, the client may suggest its preference to the server using the Accept header, as in Accept: application/json, text/plain, */* q=0.8. Some people argue that this feature of REST is not that useful, since most modern programming languages can easily handle all those formats. Most of the time, the resources will be represented using a meta-language, either in XML, JSON or YAML. The requested Media Type will be returned as long as the server supports it. REST leverages this feature to allow client applications negotiate the specific representation they are interested in. Sometimes, subdomains, query parameters or URI extensions are used as a workaround. Note there is no standardized way to return the list of possible choices. In this case, the server will return a 300 - Multiple Choices with a list of URIs for each representation. And even though HTTP includes some important selection features (type, charset, language, encoding.), it still lacks of many other useful representations, for example, currency unit or distance unit.įor all of the above, the Agent-Driven Negotiation was defined. Sometimes, it is useful to let the user agent (manually or through a script) selected the desired representation. Servers will return the selected values, as well as a Vary header to tell a cache whether a new request is needed or not. Accept-Encoding: deflate, gzip q=1.0, * q=0.5.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |