HTTP Status Code 423 – Locked
The HTTP status code 423 Locked
indicates that the resource being accessed is locked. This status code is part of the WebDAV (Web Distributed Authoring and Versioning) protocol extension to HTTP, which is used for collaborative editing and file management.
When a client attempts to retrieve, modify, or delete a resource that is locked, the server responds with a 423 status code. This indicates that the resource is currently unavailable for the requested action until the lock is released. Locks are typically used to prevent conflicting operations from multiple clients, ensuring data consistency and integrity.
Example 1: Locked Resource during PUT Operation
PUT /files/document.txt HTTP/1.1
Host: example.com
Content-Type: text/plain
Content-Length: 123
Authorization: Bearer your-access-token
[File content here]
Response:
HTTP/1.1 423 Locked
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:">
<d:lock-token-submitted>
<d:href>urn:uuid:lock-token-1234</d:href>
</d:lock-token-submitted>
</d:error>
In this example, the client attempts to update a file using a PUT request. However, the server responds with a 423 Locked status because the file is currently locked by another operation or user. The response includes an XML body with details about the lock.
Example 2: Locked Resource during DELETE Operation
DELETE /files/document.txt HTTP/1.1
Host: example.com
Authorization: Bearer your-access-token
Response:
HTTP/1.1 423 Locked
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:">
<d:lock-token-submitted>
<d:href>urn:uuid:lock-token-5678</d:href>
</d:lock-token-submitted>
</d:error>
In this example, a DELETE request is made to remove a file. However, the server returns a 423 Locked status because the file is locked by another operation. The XML response provides information about the lock preventing the deletion.
Example 3 New Scenario
# Client sends a request example. GET /example HTTP/1.1 Host: www.example.com # Server Response HTTP/1.1 423 423 Locked Date: Wed, 09 Oct 2024 23:06:25 GMT Server: ExampleServer/1.0 Content-Type: application/json { "error": "Description of the error for 423" }
Example 4: Another Scenario
# Client sends another example request. POST /another-example HTTP/1.1 Host: www.example.com # Server Response HTTP/1.1 423 423 Locked Date: Wed, 09 Oct 2024 23:06:25 GMT Server: ExampleServer/1.0 Content-Type: application/json { "error": "Detailed message for 423" }
Summary
The HTTP status code 423 Locked
is a WebDAV extension status code indicating that a resource is currently locked. It is used to maintain data integrity by preventing conflicting operations on the same resource. Clients encountering this status need to wait until the lock is removed or provide the appropriate lock token to perform the desired action.