Root
Root

Reputation: 995

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?

Upvotes: 10

Views: 22735

Answers (3)

Maheshwar Ligade
Maheshwar Ligade

Reputation: 6855

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.

Upvotes: 1

Alexander Kleinhans
Alexander Kleinhans

Reputation: 6248

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

Upvotes: 23

Rafal G.
Rafal G.

Reputation: 4432

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.

Upvotes: 7

Related Questions