用于“正在进行的作业”的最合适的HTTP状态代码。 [英] Most appropriate HTTP status code for "job in progress"

查看:126
本文介绍了用于“正在进行的作业”的最合适的HTTP状态代码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为客户提供的最合适的HTTP状态代码是什么意思是您的请求很好,但仍在进行中;请稍后在完全相同的位置查看。

What is the most appropriate HTTP status code to give to a client to mean "your request is fine, but it is still in progress; check back shortly in the exact same place."

例如,假设客户端提交初始请求以启动繁重的查询,并且服务器立即返回客户端可以定期轮询结果的URL。如果客户端在作业完成之前调用此URL,则返回的最合适的HTTP状态代码是什么?

For example, say the client submits an initial request to start a heavy query, and the server immediately returns a URL that the client can poll periodically for the result. In the case the client calls this URL before the job is completed, what is the most appropriate HTTP status code to return?

202接受将是我的第一个冲动。这是最好的一个,还是在REST接口中有更好的用于此目的?

202 Accepted would be my first impulse. Is this the best one, or is there a better one that is more idiomatic for this purpose in REST interfaces?

推荐答案

给我, 202接受将是最好的方式。

To me, 202 Accepted would be the best way to go.

参见文档


10.2.3 202接受

10.2.3 202 Accepted

该请求已被接受处理,但处理的
尚未完成。该请求最终可能会或可能不会被执行
,因为在实际处理时可能会被禁止。
没有从异步
操作中重新发送状态代码的工具。

The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. There is no facility for re-sending a status code from an asynchronous operation such as this.

202响应是故意不承诺的。它的目的是
允许服务器接受一些其他进程的请求(可能是一个
批处理导向的进程,每天只运行一次)而没有
要求用户代理连接到服务器一直持续到
流程完成。使用此响应返回的实体
应该包括请求的当前状态的指示和
指向状态监视器的指针或用户
何时可以期望满足请求的某些估计。

The 202 response is intentionally non-committal. Its purpose is to allow a server to accept a request for some other process (perhaps a batch-oriented process that is only run once per day) without requiring that the user agent's connection to the server persist until the process is completed. The entity returned with this response SHOULD include an indication of the request's current status and either a pointer to a status monitor or some estimate of when the user can expect the request to be fulfilled.

这篇关于用于“正在进行的作业”的最合适的HTTP状态代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆