Class HeaderUtils


  • public final class HeaderUtils
    extends java.lang.Object
    Utilities to use for HttpHeaders implementations.
    • Field Detail

      • DEFAULT_HEADER_FILTER

        public static final java.util.function.BiFunction<? super java.lang.CharSequence,​? super java.lang.CharSequence,​java.lang.CharSequence> DEFAULT_HEADER_FILTER
    • Method Detail

      • isTransferEncodingChunked

        public static boolean isTransferEncodingChunked​(HttpHeaders headers)
        Returns true if headers indicates transfer-encoding chunked.

        The values of all HttpHeaderNames.TRANSFER_ENCODING headers are interpreted as comma-separated values, with spaces between values trimmed. If any of these values is HttpHeaderValues.CHUNKED, this method return true, otherwise it returns false.

        Parameters:
        headers - The HttpHeaders to check.
        Returns:
        true if headers indicates transfer-encoding chunked, false otherwise.
      • domainMatches

        public static boolean domainMatches​(java.lang.CharSequence requestDomain,
                                            @Nullable
                                            java.lang.CharSequence cookieDomain)
        Parameters:
        requestDomain - The domain from the request.
        cookieDomain - The domain from the cookie.
        Returns:
        true if there is a match.
      • pathMatches

        public static boolean pathMatches​(java.lang.CharSequence requestPath,
                                          @Nullable
                                          java.lang.CharSequence cookiePath)
        Parameters:
        requestPath - The path from the request.
        cookiePath - The path from the cookie.
        Returns:
        true if there is a match.
      • hasContentType

        public static boolean hasContentType​(HttpHeaders headers,
                                             java.lang.CharSequence expectedContentType,
                                             @Nullable
                                             java.nio.charset.Charset expectedCharset)
        Checks if the provider headers contain a Content-Type header that matches the specified content type, and optionally the provided charset.
        Parameters:
        headers - the HttpHeaders instance
        expectedContentType - the content type to look for, provided as a type/subtype
        expectedCharset - an optional charset constraint.
        Returns:
        true if a Content-Type header that matches the specified content type, and optionally the provided charset has been found, false otherwise.
        See Also:
        Syntax of the Content-Type Header Field