Class HttpHeaderCollection


  • public class HttpHeaderCollection
    extends Object
    A multivalue map of headers names and header values suitable for processing http request and response headers.
    Since:
    1.5
    Author:
    Peter Ertl
    • Method Detail

      • setHeader

        public void setHeader​(String name,
                              String value)
        set header value (and remove previous values)
        Parameters:
        name - header name
        value - header value
      • addHeader

        public void addHeader​(String name,
                              String value)
        add header value
        Parameters:
        name - header name
        value - header value
      • addDateHeader

        public void addDateHeader​(String name,
                                  Instant time)
        add date header value
        Parameters:
        name - header name
        time - timestamp
      • setDateHeader

        public void setDateHeader​(String name,
                                  Instant time)
        add date header value
        Parameters:
        name - header name
        time - timestamp
      • removeHeader

        public void removeHeader​(String name)
        remove header values for header name
        Parameters:
        name - header name
      • containsHeader

        public boolean containsHeader​(String name)
        check if header is defined
        Parameters:
        name - header name
        Returns:
        true if header has one or more values
      • getHeaderValues

        public String[] getHeaderValues​(String name)
        get header values (dates will be converted into strings)
        Parameters:
        name - header name
        Returns:
        array of header values or empty array if not found
      • getHeader

        public String getHeader​(String name)
        Gets the header identified with the name as a String.
        Parameters:
        name -
        Returns:
        null when the header was not found
      • getDateHeader

        public Instant getDateHeader​(String name)
        Gets the header identified with the name as a Time
        Parameters:
        name -
        Returns:
        null when the header was not found
      • isEmpty

        public boolean isEmpty()
        Check if collection is empty
        Returns:
        true if collection is empty, false otherwise
      • getCount

        public int getCount()
        get number of headers
        Returns:
        count
      • clear

        public void clear()
        clear all headers