Class DigestFields

java.lang.Object
org.apache.hc.core5.http.digest.DigestFields

public final class DigestFields extends Object
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
  • Constructor Details

    • DigestFields

      private DigestFields()
  • Method Details

    • parseDigest

      public static StructuredFieldDictionary parseDigest(Header header) throws ParseException
      Parses and validates a Content-Digest or Repr-Digest field 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 one Content-Digest or Repr-Digest dictionary.
      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

      public static StructuredFieldDictionary parsePreferences(Header header) throws ParseException
      Parses and validates a Want-Content-Digest or Want-Repr-Digest field 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 one Want-Content-Digest or Want-Repr-Digest dictionary.
      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

      public static Header formatDigest(String name, StructuredFieldDictionary value)
      Formats a validated Content-Digest or Repr-Digest dictionary.
      Parameters:
      name - the field name.
      value - the digest dictionary.
      Returns:
      the formatted header, or null for an empty dictionary.
      Throws:
      IllegalArgumentException - if any dictionary member is not a Byte Sequence item.
    • formatPreferences

      public static Header formatPreferences(String name, StructuredFieldDictionary value)
      Formats a validated Want-Content-Digest or Want-Repr-Digest dictionary.
      Parameters:
      name - the field name.
      value - the preference dictionary.
      Returns:
      the formatted header, or null for an empty dictionary.
      Throws:
      IllegalArgumentException - if a member is not an Integer item or its value is outside the range 0..10.
    • validateParsedDigest

      private static StructuredFieldDictionary validateParsedDigest(StructuredFieldDictionary dictionary) throws ParseException
      Throws:
      ParseException
    • validateParsedPreferences

      private static StructuredFieldDictionary validateParsedPreferences(StructuredFieldDictionary dictionary) throws ParseException
      Throws:
      ParseException
    • validateDigest

      private static void validateDigest(StructuredFieldDictionary dictionary)
    • validatePreferences

      private static void validatePreferences(StructuredFieldDictionary dictionary)
    • requireItem

      private static StructuredFieldItem requireItem(Map.Entry<String, StructuredFieldMember> entry, String description)