What Is a 202 Status Code?
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 in HTTP for re-sending a status code from an asynchronous operation.
The 202 response is intentionally noncommittal. 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 representation sent with this response ought to describe the request’s current status and point to (or embed) a status monitor that can provide the user with an estimate of when the request will be fulfilled.
- Source: RFC7231 Section 6.3.3
202 CODE REFERENCES
Rails HTTP Status Symbol
Go HTTP Status Constant
Symfony HTTP Status Constant
Python2 HTTP Status Constant
Python3+ HTTP Status Constant
Python3.5+ HTTP Status Constant
When is a 202 status code used?
An HTTP 202 status code is used when a server receives the HTTP request and intends to process it.
This usually indicates that the server has validated the request’s format and has placed it in an internal queue for processing if it’s a long-running process or daily operation.
The client will need to periodically check the outcome of the HTTP response because the server has no way to return a status that would indicate the eventual outcome.
Once the 200 OK status is received, the client can stop checking on the response.
How to check a 202 status code
Because a server can’t return a status that would allow the client to see the eventual outcome of the request, the client will need to check the progress of the request.
A GET request to check on the status of the process or job.
202 status code example
If you want to see a 202 Accepted status code in action, we’ve got you covered. For this example, let’s say a client wants to data to a server to define a job that needs completed.
The server will respond that the request was received and acknowledged. The client will then need to send additional requests to determine whether the job has been completed. Eventually, the server will respond with a 200 OK status code when the job is finished.
POST /job HTTP/1.1
HTTP/1.1 202 Accepted
Link: </job/status/123> rel=”http://www.example.com/job-status”
Response to request #2
HTTP/1.1 202 Accepted
Response to request #3
HTTP/1.1 200 OK
Once the client receives the 200 OK status, the client can stop sending status requests and act accordingly.
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs