Interface HttpFields

All Superinterfaces:
Iterable<HttpField>, Supplier<HttpFields>
All Known Subinterfaces:
HttpFields.Mutable
All Known Implementing Classes:
HttpFields.ImmutableHttpFields, HttpFields.Mutable.Wrapper, HttpFields.MutableHttpFields, HttpTester.Message, HttpTester.Request, HttpTester.Response

public interface HttpFields extends Iterable<HttpField>, Supplier<HttpFields>
Interface that represents on ordered collection of HttpFields. Both HttpFields.MutableHttpFields and HttpFields.ImmutableHttpFields implementations are available via the static methods such as build() and from(HttpField...). To implement this interface, only the Iterable.iterator() method need be implemented, however default implementations may be inefficient
  • Field Details

    • EXPIRES_01JAN1970

      static final HttpField EXPIRES_01JAN1970
    • CONNECTION_CLOSE

      static final HttpField CONNECTION_CLOSE
    • CONNECTION_KEEPALIVE

      static final HttpField CONNECTION_KEEPALIVE
    • CONTENT_LENGTH_0

      static final HttpField CONTENT_LENGTH_0
    • EMPTY

      static final HttpFields EMPTY
  • Method Details

    • build

      static HttpFields.Mutable build()
    • build

      static HttpFields.Mutable build(int capacity)
    • build

      static HttpFields.Mutable build(HttpFields fields)
    • build

      static HttpFields.Mutable build(HttpFields fields, HttpField replaceField)
    • build

      static HttpFields.Mutable build(HttpFields fields, EnumSet<HttpHeader> removeFields)
    • from

      static HttpFields.ImmutableHttpFields from(HttpField... fields)
    • from

    • asImmutable

      default HttpFields asImmutable()
    • get

      default HttpFields get()

      Supplies this instance, typically used to supply HTTP trailers.

      Specified by:
      get in interface Supplier<HttpFields>
      Returns:
      this instance
    • takeAsImmutable

      default HttpFields takeAsImmutable()
      Efficiently take the fields as an Immutable that cannot be changed by any further mutations to this instance.
      Returns:
      An immutable version of the fields.
    • asString

      default String asString()
    • contains

      default boolean contains(HttpField field)
    • contains

      default boolean contains(HttpHeader header, String value)
    • contains

      default boolean contains(String name, String value)
    • contains

      default boolean contains(HttpHeader header)
    • contains

      default boolean contains(EnumSet<HttpHeader> headers)
    • contains

      default boolean contains(String name)
    • get

      default String get(HttpHeader header)
    • get

      default String get(String header)
    • getCSV

      default List<String> getCSV(HttpHeader header, boolean keepQuotes)
      Get multiple field values of the same name, split as a QuotedCSV
      Parameters:
      header - The header
      keepQuotes - True if the fields are kept quoted
      Returns:
      List the values with OWS stripped
    • getCSV

      default List<String> getCSV(String name, boolean keepQuotes)
      Get multiple field values of the same name as a QuotedCSV
      Parameters:
      name - the case-insensitive field name
      keepQuotes - True if the fields are kept quoted
      Returns:
      List the values with OWS stripped
    • getDateField

      default long getDateField(String name)
      Get a header as a date value. Returns the value of a date field, or -1 if not found. The case of the field name is ignored.
      Parameters:
      name - the case-insensitive field name
      Returns:
      the value of the field as a number of milliseconds since unix epoch
    • getDateField

      default long getDateField(HttpHeader header)
      Get a header as a date value. Returns the value of a date field, or -1 if not found. The case of the field name is ignored.
      Parameters:
      header - the header
      Returns:
      the value of the field as a number of milliseconds since unix epoch
    • parseDateField

      static long parseDateField(HttpField field)
    • getField

      default HttpField getField(int index)
      Get a Field by index.
      Parameters:
      index - the field index
      Returns:
      A Field value or null if the Field value has not been set
    • getField

      default HttpField getField(HttpHeader header)
    • getField

      default HttpField getField(String name)
    • getFieldNames

      @Deprecated default Enumeration<String> getFieldNames()
      Deprecated.
      Get enumeration of header _names. Returns an enumeration of strings representing the header _names for this request.
      Returns:
      an enumeration of field names
    • getFieldNamesCollection

      default Set<String> getFieldNamesCollection()
      Get Set of header names.
      Returns:
      the unique set of field names.
    • getFields

      default List<HttpField> getFields(HttpHeader header)
      Get multiple fields of the same header
      Parameters:
      header - the header
      Returns:
      List the fields
    • getFields

      default List<HttpField> getFields(String name)
    • getLongField

      default long getLongField(String name) throws NumberFormatException
      Get a header as an long value. Returns the value of an integer field or -1 if not found. The case of the field name is ignored.
      Parameters:
      name - the case-insensitive field name
      Returns:
      the value of the field as a long
      Throws:
      NumberFormatException - If bad long found
    • getLongField

      default long getLongField(HttpHeader header) throws NumberFormatException
      Get a header as an long value. Returns the value of an integer field or -1 if not found. The case of the field name is ignored.
      Parameters:
      header - the header type
      Returns:
      the value of the field as a long
      Throws:
      NumberFormatException - If bad long found
    • getQualityCSV

      default List<String> getQualityCSV(HttpHeader header)
      Get multiple field values of the same name, split and sorted as a QuotedQualityCSV
      Parameters:
      header - The header
      Returns:
      List the values in quality order with the q param and OWS stripped
    • getQualityCSV

      default List<String> getQualityCSV(HttpHeader header, ToIntFunction<String> secondaryOrdering)
      Get multiple field values of the same name, split and sorted as a QuotedQualityCSV
      Parameters:
      header - The header
      secondaryOrdering - Function to apply an ordering other than specified by quality
      Returns:
      List the values in quality order with the q param and OWS stripped
    • getQualityCSV

      default List<String> getQualityCSV(String name)
      Get multiple field values of the same name, split and sorted as a QuotedQualityCSV
      Parameters:
      name - the case-insensitive field name
      Returns:
      List the values in quality order with the q param and OWS stripped
    • getValues

      default Enumeration<String> getValues(String name)
      Get multi headers
      Parameters:
      name - the case-insensitive field name
      Returns:
      Enumeration of the values
    • getValuesList

      default List<String> getValuesList(HttpHeader header)
      Get multiple field values of the same name
      Parameters:
      header - the header
      Returns:
      List the values
    • getValuesList

      default List<String> getValuesList(String name)
      Get multiple header of the same name
      Parameters:
      name - the case-insensitive field name
      Returns:
      List the header values
    • isEqualTo

      default boolean isEqualTo(HttpFields that)
    • size

      default int size()
    • stream

      default Stream<HttpField> stream()