Class DigestFields
java.lang.Object
org.apache.hc.core5.http.digest.DigestFields
Support for Digest Fields as defined by RFC 9530.
Digest fields are Structured Field Dictionaries. Syntax parsing and
serialization is therefore delegated to the RFC 9651 implementation in
StructuredFieldHeaders. This class only applies the additional
semantic constraints imposed by RFC 9530.
- Since:
- 5.5
-
Method Summary
Modifier and TypeMethodDescriptionstatic HeaderformatDigest(String name, StructuredFieldDictionary value) Formats a validatedContent-DigestorRepr-Digestdictionary.static HeaderformatPreferences(String name, StructuredFieldDictionary value) Formats a validatedWant-Content-DigestorWant-Repr-Digestdictionary.static StructuredFieldDictionaryparseDigest(Header header) Parses and validates aContent-DigestorRepr-Digestfield value.static StructuredFieldDictionaryparseDigest(MessageHeaders headers, String name) Parses and validates all field lines with the given name as oneContent-DigestorRepr-Digestdictionary.static StructuredFieldDictionaryparsePreferences(Header header) Parses and validates aWant-Content-DigestorWant-Repr-Digestfield value.static StructuredFieldDictionaryparsePreferences(MessageHeaders headers, String name) Parses and validates all field lines with the given name as oneWant-Content-DigestorWant-Repr-Digestdictionary.
-
Method Details
-
parseDigest
Parses and validates aContent-DigestorRepr-Digestfield value.- Parameters:
header- the header to parse.- Returns:
- the parsed digest dictionary.
- Throws:
ParseException- if the field is syntactically invalid or any dictionary member is not a Byte Sequence item.
-
parseDigest
public static StructuredFieldDictionary parseDigest(MessageHeaders headers, String name) throws ParseException Parses and validates all field lines with the given name as oneContent-DigestorRepr-Digestdictionary.- Parameters:
headers- the message headers.name- the field name.- Returns:
- the parsed digest dictionary, or an empty dictionary if the field is not present.
- Throws:
ParseException- if the field is syntactically invalid or any dictionary member is not a Byte Sequence item.
-
parsePreferences
Parses and validates aWant-Content-DigestorWant-Repr-Digestfield value.- Parameters:
header- the header to parse.- Returns:
- the parsed preference dictionary.
- Throws:
ParseException- if the field is syntactically invalid, a member is not an Integer item, or its value is outside the range 0..10.
-
parsePreferences
public static StructuredFieldDictionary parsePreferences(MessageHeaders headers, String name) throws ParseException Parses and validates all field lines with the given name as oneWant-Content-DigestorWant-Repr-Digestdictionary.- Parameters:
headers- the message headers.name- the field name.- Returns:
- the parsed preference dictionary, or an empty dictionary if the field is not present.
- Throws:
ParseException- if the field is syntactically invalid, a member is not an Integer item, or its value is outside the range 0..10.
-
formatDigest
Formats a validatedContent-DigestorRepr-Digestdictionary.- Parameters:
name- the field name.value- the digest dictionary.- Returns:
- the formatted header, or
nullfor an empty dictionary. - Throws:
IllegalArgumentException- if any dictionary member is not a Byte Sequence item.
-
formatPreferences
Formats a validatedWant-Content-DigestorWant-Repr-Digestdictionary.- Parameters:
name- the field name.value- the preference dictionary.- Returns:
- the formatted header, or
nullfor an empty dictionary. - Throws:
IllegalArgumentException- if a member is not an Integer item or its value is outside the range 0..10.
-