Interface Headers

All Superinterfaces:
Iterable<Map.Entry<String,List<String>>>, Parameters
All Known Subinterfaces:
BodyPartHeaders, RequestHeaders, ResponseHeaders, WebClientRequestHeaders, WebClientResponseHeaders
All Known Implementing Classes:
HashHeaders, ReadableBodyPartHeaders, ReadOnlyHeaders, WriteableBodyPartHeaders

public interface Headers extends Parameters
Extends Parameters interface by adding methods convenient for HTTP headers.
  • Method Details

    • all

      List<String> all(String headerName)
      Returns an unmodifiable List of all header fields - each element represents a value of a single header field in the request. Consider to use value(String) or values(String) method instead.

      Always returns a List, which may be empty if the parameter is not present.

      Specified by:
      all in interface Parameters
      Parameters:
      headerName - the header name
      Returns:
      a List of values with zero or greater size
      Throws:
      NullPointerException - if headerName is null
      See Also:
    • value

      default Optional<String> value(String headerName)
      Returns a header value as a single String potentially concatenated using comma character from all header fields.

      Accordingly to RFC2616, Message Headers:

      Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma.
      Parameters:
      headerName - the header name
      Returns:
      all header values concatenated using comma separator
      Throws:
      NullPointerException - if headerName is null
      See Also:
    • values

      default List<String> values(String headerName)
      Returns an unmodifiable List of all comma separated header value parts - Such segmentation is NOT valid for all header semantics, however it is very common. Refer to actual header semantics standard/description before use.

      Result is composed from all header fields with requested headerName where each header value is tokenized by a comma character. Tokenization respects value quoting by double-quote character.

      Always returns a List, which may be empty if the parameter is not present.

      Parameters:
      headerName - the header name
      Returns:
      a List of values with zero or greater size, never null
      Throws:
      NullPointerException - if headerName is null
      See Also: