Record Class Field

java.lang.Object
java.lang.Record
org.microproxy.frames.Field
Record Components:
name - the field name
value - the field value
sensitive - whether the field must never be added to a compression table (HPACK and QPACK's never-indexed literals): kept when a field is edited with withValue(String)

public record Field(String name, String value, boolean sensitive) extends Record
One field of a decoded header block (HTTP/2 HPACK, HTTP/3 QPACK): a name, which is lower case on the wire and starts with : for a pseudo-header, and a value.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Field(String name, String value)
    Creates a field that compression tables may hold.
    Field(String name, String value, boolean sensitive)
    Creates a field.
  • 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.
    boolean
    Whether this is a pseudo-header (:method, :status, ...).
    Returns the value of the name record component.
    boolean
    Returns the value of the sensitive record component.
    final String
    Returns a string representation of this record class.
    static void
    validate(List<Field> fields)
    Checks that fields can be sent as an HTTP/2 or HTTP/3 header block: names that are non-empty lower-case tokens; values without NUL, CR or LF and without leading or trailing white space; pseudo-headers that are known (:method, :scheme, :authority, :path, :protocol or :status), not repeated, all before the regular fields, and not mixing a request's with a response's; and no connection-specific field (connection, keep-alive, proxy-connection, transfer-encoding, upgrade, and te other than trailers).
    Returns the value of the value record component.
    withValue(String newValue)
    This field with another value.

    Methods inherited from class java.lang.Object

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

    • Field

      public Field(String name, String value, boolean sensitive)
      Creates a field.
      Parameters:
      name - the field name
      value - the field value
      sensitive - whether the field must never be added to a compression table
      Throws:
      NullPointerException - if the name or value is null
    • Field

      public Field(String name, String value)
      Creates a field that compression tables may hold.
      Parameters:
      name - the field name
      value - the field value
  • Method Details

    • withValue

      public Field withValue(String newValue)
      This field with another value.
      Parameters:
      newValue - the new value
      Returns:
      a copy with newValue
    • isPseudo

      public boolean isPseudo()
      Whether this is a pseudo-header (:method, :status, ...).
      Returns:
      whether the name starts with a colon
    • validate

      public static void validate(List<Field> fields)
      Checks that fields can be sent as an HTTP/2 or HTTP/3 header block: names that are non-empty lower-case tokens; values without NUL, CR or LF and without leading or trailing white space; pseudo-headers that are known (:method, :scheme, :authority, :path, :protocol or :status), not repeated, all before the regular fields, and not mixing a request's with a response's; and no connection-specific field (connection, keep-alive, proxy-connection, transfer-encoding, upgrade, and te other than trailers). Whether the block is a complete request or response is not checked here.
      Parameters:
      fields - the header block
      Throws:
      IllegalArgumentException - naming the first problem
    • toString

      public final 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