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?
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With