Class HttpHeader


  • public final class HttpHeader
    extends java.lang.Object
    An HTTP header consisting of a name and one or more values.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @NonNull HttpHeader append​(@NonNull java.lang.String value)
      Append a single value to this header.
      @NonNull HttpHeader append​(@NonNull java.util.List<@NonNull java.lang.String> values)
      Append multiple value to this header.
      static @NonNull HttpHeader contentLength​(long contentLength)
      Create a Content-Length header.
      static @NonNull HttpHeader contentType​(@NonNull ContentType contentType)
      Create a Content-Type header from the given ContentType.
      @NonNull java.lang.String displayName()
      The header name with its original capitalization for prettier printing.
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      static @NonNull HttpHeader lastModified​(@NonNull java.time.Instant lastModified)
      Create a Last-Modified header from the given Instant.
      @NonNull java.lang.String name()
      The normalized header name for case-insensitive comparisons.
      boolean nameEquals​(@NonNull java.lang.String other)
      Return true if the given header name refers to the same header as this one.
      static @NonNull HttpHeader of​(@NonNull java.lang.String name, @NonNull java.lang.String value)
      Create a header with the given name and single value.
      static @NonNull HttpHeader of​(@NonNull java.lang.String name, @NonNull java.util.List<@NonNull java.lang.String> values)
      Create a header with the given name and values.
      java.lang.String toString()  
      @NonNull java.util.List<@NonNull java.lang.String> values()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LAST_MODIFIED

        @NonNull
        public static final @NonNull java.lang.String LAST_MODIFIED
        See Also:
        Constant Field Values
      • CONTENT_TYPE

        @NonNull
        public static final @NonNull java.lang.String CONTENT_TYPE
        See Also:
        Constant Field Values
      • CONTENT_LENGTH

        @NonNull
        public static final @NonNull java.lang.String CONTENT_LENGTH
        See Also:
        Constant Field Values
      • CONTENT_ID

        @NonNull
        public static final @NonNull java.lang.String CONTENT_ID
        See Also:
        Constant Field Values
      • OPERATION_TYPE

        @NonNull
        public static final @NonNull java.lang.String OPERATION_TYPE
        See Also:
        Constant Field Values
      • AUTHORIZATION

        @NonNull
        public static final @NonNull java.lang.String AUTHORIZATION
        See Also:
        Constant Field Values
    • Method Detail

      • append

        @NonNull
        public @NonNull HttpHeader append​(@NonNull
                                          @NonNull java.lang.String value)
        Append a single value to this header.
        Parameters:
        value - the new value to append
        Returns:
        a new HttpHeader with the given value appended
      • append

        @NonNull
        public @NonNull HttpHeader append​(@NonNull
                                          @NonNull java.util.List<@NonNull java.lang.String> values)
        Append multiple value to this header.
        Parameters:
        values - the values to append
        Returns:
        a new HttpHeader with the given values appended
      • nameEquals

        public boolean nameEquals​(@NonNull
                                  @NonNull java.lang.String other)
        Return true if the given header name refers to the same header as this one. Since HTTP header names are case-insensitive, this performs a case-insensitive comparison between the string and this header's name.
        Parameters:
        other - the string to compare to
        Returns:
        true if the given string matches this header's name
      • of

        @NonNull
        public static @NonNull HttpHeader of​(@NonNull
                                             @NonNull java.lang.String name,
                                             @NonNull
                                             @NonNull java.lang.String value)
        Create a header with the given name and single value.
        Parameters:
        name - the header name
        value - the single header value
        Returns:
        the HttpHeader for the given name and value
      • of

        @NonNull
        public static @NonNull HttpHeader of​(@NonNull
                                             @NonNull java.lang.String name,
                                             @NonNull
                                             @NonNull java.util.List<@NonNull java.lang.String> values)
        Create a header with the given name and values.
        Parameters:
        name - the header name
        values - the list of header values
        Returns:
        the HttpHeader for the given name and value
      • contentType

        @NonNull
        public static @NonNull HttpHeader contentType​(@NonNull
                                                      @NonNull ContentType contentType)
        Create a Content-Type header from the given ContentType.
        Parameters:
        contentType - the content type
        Returns:
        the Content-Type HttpHeader
      • contentLength

        @NonNull
        public static @NonNull HttpHeader contentLength​(long contentLength)
        Create a Content-Length header.
        Parameters:
        contentLength - the content length value
        Returns:
        the Content-Length HttpHeader
      • lastModified

        @NonNull
        public static @NonNull HttpHeader lastModified​(@NonNull
                                                       @NonNull java.time.Instant lastModified)
        Create a Last-Modified header from the given Instant. The Instant is formatted in the preferred HTTP datetime header format. Example: Wed, 04 Oct 2023 08:25:33 GMT
        Parameters:
        lastModified - the timestamp
        Returns:
        the Last-Modified HttpHeader
      • name

        @NonNull
        public @NonNull java.lang.String name()
        The normalized header name for case-insensitive comparisons.
      • displayName

        @NonNull
        public @NonNull java.lang.String displayName()
        The header name with its original capitalization for prettier printing.
      • values

        @NonNull
        public @NonNull java.util.List<@NonNull java.lang.String> values()
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object