Interface Header

All Superinterfaces:
Value<String>
All Known Subinterfaces:
HeaderWriteable
All Known Implementing Classes:
ContentDisposition

public interface Header extends Value<String>
HTTP Header with HeaderName and value.
See Also:
  • Method Details

    • name

      String name()
      Name of the header as configured by user or as received on the wire.
      Specified by:
      name in interface Value<String>
      Returns:
      header name, always lower case for HTTP/2 headers
    • headerName

      HeaderName headerName()
      Header name for the header.
      Returns:
      header name
    • values

      default String values()
      All values concatenated using a comma and a space.
      Returns:
      all values joined by a comma
    • allValues

      List<String> allValues()
      All values of this header.
      Returns:
      all configured values
    • allValues

      default List<String> allValues(boolean split)
      All values of this header. If this header is defined as a single header with comma separated values, set split to true.
      Parameters:
      split - whether to split single value by comma, does nothing if the value is already a list.
      Returns:
      list of values
    • valueCount

      int valueCount()
      Number of values this header has.
      Returns:
      number of values (minimal number is 1)
    • sensitive

      boolean sensitive()
      Sensitive headers should not be logged, or indexed (HTTP/2).
      Returns:
      whether this header is sensitive
    • changing

      boolean changing()
      Changing headers should not be cached, and their value should not be indexed (HTTP/2).
      Returns:
      whether this header's value is changing often
    • valueBytes

      default byte[] valueBytes()
      Bytes of a single-valued header value.

      Each character in the value is mapped to the byte with the same numeric value using StandardCharsets.ISO_8859_1. Characters from U+0080 through U+00FF therefore represent opaque HTTP field-value octets; they are not interpreted as UTF-8 or as ISO-8859-1 text.

      Returns:
      a new byte array containing the value bytes
      Throws:
      IllegalArgumentException - if the value contains a character above U+00FF
    • writeHttp1Header

      default void writeHttp1Header(BufferData buffer)
      Write the current header as an HTTP header to the provided buffer.
      Parameters:
      buffer - buffer to write to (should be growing)
    • validate

      default void validate() throws IllegalArgumentException
      Check validity of the header name and values.

      The name must be a non-empty HTTP token. Values may contain opaque octets represented by characters from U+0080 through U+00FF; characters above U+00FF cannot be represented in an HTTP field value and are rejected.

      Throws:
      IllegalArgumentException - if the header name or a value is not valid