Ci sono due risposte simili che dovrebbero essere considerate a seconda di quale dovrebbe essere la risposta attesa.
La 202 risposta accettata è una risposta "sì, ottenuto". La risorsa viene creata e il server cercherà di fare qualcosa con questo.
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.
( link )
L'altra risposta da guardare è la 201 risposta creata:
The request has been fulfilled and resulted in a new resource being created. The newly created resource can be referenced by the URI(s) returned in the entity of the response, with the most specific URI for the resource given by a Location header field. The response SHOULD include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field. The origin server MUST create the resource before returning the 201 status code. If the action cannot be carried out immediately, the server SHOULD respond with 202 (Accepted) response instead.
( link )
In particolare, la risposta 201 risponde con la posizione della risorsa che è stata creata. Questa parte corrisponde alla descrizione del tuo requisito:
... the resource POSTed is created immediately, it's just the resulting task that affects the user which is delayed ...
Post di blog correlati: