HTTP Headers
Want Content Digest
The HTTP Want-Content-Digest
request and response headers indicate a preference for the recipient to send a Content-Digest
integrity header in messages associated with the request URI and representation metadata.
The header includes hashing algorithm preferences that the recipient can use in subsequent messages.
The preferences only serve as a hint, and the recipient may ignore the algorithm choices, or the integrity headers entirely.
Some implementations may send unsolicited Content-Digest
headers without requiring a Want-Content-Digest
header in a previous message.
The relevant details concerning header types are summarized below:
Representation header
Forbidden request header: No
Syntax
A comma-separated list of one or more hashing algorithms:
Want-Content-Digest: <algorithm>=<preference>
Want-Content-Digest: <algorithm>=<preference>, …, <algorithmN>=<preferenceN>
Directives
Directives
- <algorithm>
The specified algorithm used to generate a message digest. Only two digest algorithms are considered secure:
sha-512
andsha-256
. The insecure (legacy) algorithms include:md5
,sha (SHA-1),
unixsum
,unixcksum
,adler
(ADLER32), andcrc32c
.- <preference>
An integer from 0 to 9 indicating preference where
0
means "not acceptable". Values from1
to9
indicate increasing preference. Unlike earlier drafts, the preference weights are not expressed viaq
quality values.
Example
Examples
The following message requests the recipient to include a <Content-Digest>
header using the SHA-512 algorithm:
Want-Content-Digest: sha-512=9
The header below specifies three algorithms, with SHA-256 as the preferred digest algorithm for the recipient to use, followed by SHA-512 and MD5:
Want-Content-Digest: md5=1, sha-512=2, sha-256=3
This header does not have a standard browser integration (“browser compatibility” does not apply).
Developers can set and retrieve HTTP headers using fetch()
in order to implement application-specific behavior.
How to Modify Header using Requestly
- Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
- Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
- Add a new header modification:
- Under “Action”, select “Add” or “Override”.
- In the “Header Name” field, enter Want Content Digest.
- In the “Header Value” field, enter the desired digest algorithm or value (e.g., sha-256).
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
- Save the rule.
Once set up, Requestly will inject the Want Content Digest header into all matching requests, allowing you to test how your server validates content digests or simulate client requests needing content integrity checks.
Modifying the Want Content Digest header helps you verify that your server correctly handles content integrity validation, which is important to ensure data hasn’t been tampered with during transfer. It also helps developers test different digest algorithms to improve security or debug related issues easily.
Table of Contents
- No headings found.