Interface HttpHeaders

  • All Known Implementing Classes:
    HttpHeadersImpl


    public interface HttpHeaders
    A read-only view of a set of HTTP headers.
    Since:
    9
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.String> allValues(java.lang.String name)
      Returns an unmodifiable List of all of the values of the given named header.
      java.util.Optional<java.lang.String> firstValue(java.lang.String name)
      Returns an Optional containing the first value of the given named (and possibly multi-valued) header.
      java.util.OptionalLong firstValueAsLong(java.lang.String name)
      Returns an OptionalLong containing the first value of the named header field.
      java.util.Map<java.lang.String,java.util.List<java.lang.String>> map()
      Returns an unmodifiable multi Map view of this HttpHeaders.
    • Method Detail

      • firstValue

        java.util.Optional<java.lang.String> firstValue(java.lang.String name)
        Returns an Optional containing the first value of the given named (and possibly multi-valued) header. If the header is not present, then the returned Optional is empty.
        Parameters:
        name - the header name
        Returns:
        an Optional<String> for the first named value
      • firstValueAsLong

        java.util.OptionalLong firstValueAsLong(java.lang.String name)
        Returns an OptionalLong containing the first value of the named header field. If the header is not present, then the Optional is empty. If the header is present but contains a value that does not parse as a Long value, then an exception is thrown.
        Parameters:
        name - the header name
        Returns:
        an OptionalLong
        Throws:
        java.lang.NumberFormatException - if a value is found, but does not parse as a Long
      • allValues

        java.util.List<java.lang.String> allValues(java.lang.String name)
        Returns an unmodifiable List of all of the values of the given named header. Always returns a List, which may be empty if the header is not present.
        Parameters:
        name - the header name
        Returns:
        a List of String values
      • map

        java.util.Map<java.lang.String,java.util.List<java.lang.String>> map()
        Returns an unmodifiable multi Map view of this HttpHeaders. This interface should only be used when it is required to iterate over the entire set of headers.
        Returns:
        the Map