102 Processing
Description
The 102 Processing
status code is an informational HTTP response status that indicates the server has received and is processing the request, but no response is available yet. This status code prevents the client from timing out and assuming the request was lost.
This status code is particularly useful for complex operations that require significant server processing time, such as extensive database operations, file processing, or external service interactions. It allows the server to inform the client that the request is still being processed and hasn't been rejected or forgotten.
The 102 Processing
status was introduced in the WebDAV protocol extension (RFC 2518) and is commonly used in scenarios where operations may take a long time to complete, especially in distributed systems.
Syntax
The server sends a 102 Processing
status while it works on the request:
The server may send multiple 102 Processing responses while handling a lengthy operation. Eventually, the server will send a final response with an appropriate status code (such as 200 OK, 201 Created, etc.) once processing is complete.
Examples
WebDAV COPY Operation Example
A client initiates a WebDAV COPY operation to duplicate a large directory structure:
Client Request:
COPY /source-directory/ HTTP/1.1
Host: example.com
Destination: /destination-directory/
Depth: infinity
Server Interim Response:
After some time, the server might send another 102 Processing response to keep the connection alive:
Server Interim Response (after 30 seconds):
Once the operation completes:
Server Final Response:
HTTP/1.1 201 Created
Content-Type: application/xml
Content-Length: 152
<?xml version="1.0" encoding="UTF-8"?>
<d:multistatus xmlns:d="DAV:">
<d:response>
<d:href>/destination-directory/</d:href>
<d:status>HTTP/1.1 201 Created</d:status>
</d:response>
</d:multistatus>
Complex API Operation Example
A client initiates a resource-intensive operation through an API:
Client Request:
POST /generate-report HTTP/1.1
Host: api.example.com
Content-Type: application/json
Content-Length: 245
{
"reportType": "annual",
"dataPoints": ["revenue", "expenses", "growth"],
"timeframe": {
"start": "2022-01-01",
"end": "2022-12-31"
},
"format": "pdf",
"includeGraphs": true
}
Server Interim Response:
After the report is generated:
Server Final Response:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 157
{
"status": "complete",
"reportId": "AR2022-12345",
"downloadUrl": "https://api.example.com/reports/AR2022-12345.pdf",
"pageCount": 42
}
Summary
The 102 Processing
status code serves as a communication mechanism for long-running operations, preventing client timeouts and connection drops during extended processing periods. It's particularly valuable in distributed systems, WebDAV operations, and complex API requests that require significant server-side processing. By sending periodic 102 responses, servers can maintain the connection and inform clients that their request is still being actively processed.