Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should be the Http Status code for Request pending?

I have a server that takes a file, analyse it and sends back the result when requested by the client. In some cases there are some files that are inserted in a queue and waits for a analyser to do its job. At the same time if the analysis result is pending client can request for a result. So what should be the Http status code in this case?

like image 608
Root Avatar asked May 10 '16 06:05

Root


Video Answer


3 Answers

Per the w3c spec, 202 means that that status has been accepted by the server (and is still processing).

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

like image 169
Alexander Kleinhans Avatar answered Oct 02 '22 09:10

Alexander Kleinhans


I would go with 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.

like image 31
Rafal G. Avatar answered Oct 02 '22 10:10

Rafal G.


There is no specific separate status code for the pending request. You can predicate it from the status code 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 status code series means Success, means request heated to the server & it is in process.

like image 21
Maheshwar Ligade Avatar answered Oct 02 '22 09:10

Maheshwar Ligade