We are trying to create a REST interface that allows users to check for a specific resource. Suppose we sell domain names: the user needs to determine if the domain is available.
HTTP GETin conjunction with the codes of responses 200and 404it seems at first glance reasonable.
The problem is that we distinguish between a query that is successfully served by our search service and a query that is executed when the other components behave exclusively. For instance:
404and 200can be returned by intermediate proxies that actually block the request. This may be due to improper proxy configuration or even external infrastructure such as a Wifi coffee maker using poor forms-based authentication.
Customers may use broken URLs. This can happen through obsolescence or (again) by incorrect configuration. However, we could fight the first with help 301.
What is the current best practice for distinguishing between responses that were successfully executed against the clientβs intentions for this request and responses received through exceptional behavior?
The problem is resolved by tunneling the responses through the response body, as we can guarantee that they are unique to our service. However, it seems not very RESTful!
source
share