待处理请求的 Http 状态代码应该是什么?

What should be the Http Status code for Request pending?

我有一个服务器,它获取一个文件,对其进行分析并在客户端请求时发回结果。在某些情况下,有些文件被插入到队列中并等待分析器完成其工作。同时如果分析结果为pending客户端可以请求结果。那么在这种情况下 Http status 代码应该是什么?

我会选择 202:

202 Accepted The request has been accepted for processing, but the processing has not been completed. The request might or might not be eventually acted upon, and may be disallowed when processing occurs.

根据 w3c 规范,202 表示该状态已被服务器接受(并且仍在处理中)。

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.

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.

https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

待处理请求没有特定的单独状态代码。 您可以从 状态码 202

中断言

The request has been accepted for processing, but the processing has not been completed. The request might or might not be eventually acted upon, and may be disallowed when processing occurs

2xx 状态代码系列表示成功,表示请求加热到服务器并且正在处理中。