开发者

Picking the right HTTP return code for future resources

I'm not sure which HTTP code is the right choice for a distinct scenario.

Clients can upload entities by using PUT to a pre-known URI. Then, the entity is processed on the server which could take some time (i.e. transcoding/processing). If this is done, the resource is available under the URI it had been uploaded to.

Now I'm unsure which is the right HTTP Response code to return, if clients query the resource before processing is done. I'm searching something like the opposite of 410 Gone. Due to the applications architecture, different clients will know the URI before processing has finished (at least the client that did the upload).

Additionally, I don't want to use WebDAV extension codes, although there would be some valid ones.

I had some initial ideas, but I don't know which fits best:

  • 307 Temporary Redirect Redirect to placeholder resource.
  • 405 Method Not Allowed GET is allowed only later => Clients must not cache this answer.
  • 503 Service Unavailable Emphasizes on server-side error => Perhaps somewhat unclear f开发者_运维问答or the client what actually got wrong.
  • Any other idea?

What should I pick?


You could return a 202 Accepted in response to the initial PUT and then 204 No Content to any GET requests until the representation is available.


There are no specific HTTP codes for your use case. Maybe you want to use WebDAV's extension 423 LOCKED:

The 423 (Locked) status code means the source or destination resource of a method is locked.


Return 202 and a response body that contains a status and a link to a resource where the status can be monitored.

When someone GETs the not yet ready resource, use a 307 to temp. redirect to that monitoring page.

This requires that the client understands the entity media type that contains the link to the monitoring resource so in machine-to-machine systems you'll need to mint a media type for this or at least some micro format if you use HTML.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜