Class HeadersUtils


  • public final class HeadersUtils
    extends Object
    Provides utility methods related to Headers.
    • Method Detail

      • getAllAsString

        public static <K,​V> List<String> getAllAsString​(Headers<K,​V,​?> headers,
                                                              K name)
        Headers.get(Object) and convert each element of List to a String.
        Parameters:
        name - the name of the header to retrieve
        Returns:
        a List of header values or an empty List if no values are found.
      • getAsString

        public static <K,​V> String getAsString​(Headers<K,​V,​?> headers,
                                                     K name)
        Headers.get(Object) and convert the result to a String.
        Parameters:
        headers - the headers to get the name from
        name - the name of the header to retrieve
        Returns:
        the first header value if the header is found. null if there's no such entry.
      • toString

        public static <K,​V> String toString​(Class<?> headersClass,
                                                  Iterator<Map.Entry<K,​V>> headersIt,
                                                  int size)
        Helper for implementing toString for DefaultHeaders and wrappers such as DefaultHttpHeaders.
        Parameters:
        headersClass - the class of headers
        headersIt - the iterator on the actual headers
        size - the size of the iterator
        Returns:
        a String representation of the headers