开发者

What HTTP code should REST return for a resource that is not ready after a 202 code?

Can't seem to find the answer to this question anywhere. Have a service that when something is posted, it gets queued to be processed with a response code of 202. The standard says to provide a pointer to a status monitor, which I have done, but what should I return if the client goes to the resource before the resource is ready? I would think 404 except that the resource exists, just hasn't been processed yet.

开发者_StackOverflow中文版Thoughts?


Check this post:

When the client checks the status URI later, if the item is still pending then the status URI might return a 200 OK response with an entity body describing this. If the resource has been created, then perhaps the status URI would return a 201 Created response with a Location header pointing to the location of the new resource. If the item was not created for some reason, then perhaps the status URI would return a 410 Gone response. In this case, you should include an entity body explaining why the resource is gone, i.e. “We were unable to create this resource due to processing errors.” A 404 Not Found response would also be acceptable, but the 410 Gone response implies permanence; the requested resource is gone for good.

Seems relatively reasonable to me, except that Location header IMO is not particularly suited for this exact purpose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜