httpresthttpresponse

HTTP Response code for "Please wait a little bit"


What is the best HTTP response code for the server to send if it wants the client to wait for a little bit of time and then try the request again?

Right now, I'm using:

409 Conflict

But this doesn't feel quite right...


Solution

  • Depending on why you want them to wait, the status codes will be different. Codes that start with 4 signify client errors. If the request was done properly I would not use a 400 code. Statuses that start with 5 are for server errors. If you are asking the HTTP requestor to wait because of problems on your side, I'd go with 503.

    I came across this issue writing a web service to check if a file is finished processing. If it is done. I am returning 200, if it is not I don't want to give an error code. It would be more appropriate to use one that starts with 2 (success.) In this case the best standard code would probably be "202 Accepted" The HTTP spec describes it as:

    The request has been accepted for processing, but the processing has not been completed.