Want-Content-Digest
The HTTP Want-Content-Digest request and response header signals preference for including a Content-Digest hash in the message, allowing verification of message content integrity.
Usage
The Want-Content-Digest header indicates which hashing algorithms the client prefers and supports for content integrity verification. The server reads this header and decides whether to include a Content-Digest header in the response with a hash computed using one of the requested algorithms.
This header is part of the HTTP integrity framework, which replaced the older Want-Digest header. The Content-Digest field provides a hash of the HTTP message content, which reflects any content encodings applied. This differs from Repr-Digest, which hashes the selected representation data independent of content encoding.
Clients typically use this header when downloading files or receiving responses where data integrity matters. The server response includes the computed hash, and the client verifies the received content matches by computing its own hash and comparing values. When the hashes match, the content arrived without corruption or tampering during transmission.
The header uses a dictionary format where each algorithm name maps to a preference weight from 0 to 10. A weight of 10 indicates the highest preference, 1 indicates the lowest preference, and 0 means the algorithm is explicitly not acceptable.
Directives
The Want-Content-Digest header uses algorithm identifiers as keys and integer preference weights as values. Multiple algorithms are separated by commas.
sha-256
The sha-256 algorithm requests a SHA-256 hash digest. SHA-256 produces a
256-bit hash and is widely supported across HTTP implementations.
sha-512
The sha-512 algorithm requests a SHA-512 hash digest. SHA-512 produces a
512-bit hash and offers stronger collision resistance than SHA-256 at the
cost of larger digest size.
Preference weights
Each algorithm is followed by an equals sign and an integer from 0 to 10. Higher values indicate stronger preference. A value of 0 signals the client does not accept the algorithm.
Example
A client requesting SHA-256 integrity verification with a preference weight of 10. The server includes a Content-Digest header in the response using the requested algorithm.
Want-Content-Digest: sha-256=10
A client expressing preference for SHA-512 with a fallback to SHA-256. The
weight of 10 for SHA-256 and 3 for SHA-512 indicates SHA-256 is strongly
preferred. The unixsum=0 entry explicitly rejects the legacy Unix checksum
algorithm.
Want-Content-Digest: sha-512=3, sha-256=10, unixsum=0
A server responding with the requested content digest, computed using SHA-256 as requested by the client.
Request
Want-Content-Digest: sha-256=10
Response
Content-Digest: sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:
Takeaway
The Want-Content-Digest header signals algorithm preferences for content integrity verification, requesting the server include a Content-Digest hash in the response.