Record Class HeaderField

java.lang.Object
java.lang.Record
io.github.mahmoudimus.http2.HeaderField
Record Components:
name - the non-null field name as ISO-8859-1 octets
value - the non-null field value as ISO-8859-1 octets
sensitive - the field was, or must be, sent as a never-indexed literal (RFC 7541 §6.2.3): an intermediary must re-encode it the same way so that it never enters a compression context

public record HeaderField(String name, String value, boolean sensitive) extends Record
One header or trailer field (a name and a value) as HPACK carries it. Names and values are octet strings; they are held as Strings with one char per octet (ISO-8859-1), so no input is lost and none is reinterpreted. Http2Headers checks which octets HTTP allows.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The per-entry overhead HPACK adds to the octet lengths of name and value (RFC 7541 §4.1).
  • Constructor Summary

    Constructors
    Constructor
    Description
    HeaderField(String name, String value)
    Creates a field without an explicit never-indexed requirement.
    HeaderField(String name, String value, boolean sensitive)
    Creates a field with the given indexing sensitivity.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the name record component.
    boolean
    Returns the value of the sensitive record component.
    int
    The size HPACK and SETTINGS_MAX_HEADER_LIST_SIZE count for this field: name + value + 32.
    Returns a string representation of this record class.
    Returns the value of the value record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • ENTRY_OVERHEAD

      public static final int ENTRY_OVERHEAD
      The per-entry overhead HPACK adds to the octet lengths of name and value (RFC 7541 §4.1).
      See Also:
  • Constructor Details

    • HeaderField

      public HeaderField(String name, String value, boolean sensitive)
      Creates a field with the given indexing sensitivity.
      Parameters:
      name - the non-null field name as ISO-8859-1 octets
      value - the non-null field value as ISO-8859-1 octets
      sensitive - whether intermediaries must preserve never-indexed encoding
    • HeaderField

      public HeaderField(String name, String value)
      Creates a field without an explicit never-indexed requirement.
      Parameters:
      name - the non-null field name as ISO-8859-1 octets
      value - the non-null field value as ISO-8859-1 octets
  • Method Details

    • size

      public int size()
      The size HPACK and SETTINGS_MAX_HEADER_LIST_SIZE count for this field: name + value + 32.
      Returns:
      the field size in octets, including the 32-octet overhead
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • value

      public String value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • sensitive

      public boolean sensitive()
      Returns the value of the sensitive record component.
      Returns:
      the value of the sensitive record component