Class Headers


  • public class Headers
    extends Object
    • Constructor Detail

      • Headers

        public Headers()
      • Headers

        public Headers​(Collection<kong.unirest.core.Headers.Entry> entries)
    • Method Detail

      • add

        public void add​(String name,
                        String value)
        Add a header element
        Parameters:
        name - the name of the header
        value - the value for the header
      • add

        public void add​(String name,
                        Supplier<String> value)
        Add a header element with a supplier which will be evaluated on request
        Parameters:
        name - the name of the header
        value - the value for the header
      • replace

        public void replace​(String name,
                            String value)
        Replace a header value. If there are multiple instances it will overwrite all of them
        Parameters:
        name - the name of the header
        value - the value for the header
      • size

        public int size()
        Get the number of header keys.
        Returns:
        the size of the header keys
      • get

        public List<String> get​(String name)
        Get all the values for a header name
        Parameters:
        name - name of the header element
        Returns:
        a list of values
      • putAll

        public void putAll​(Headers header)
        Add a bunch of headers at once
        Parameters:
        header - a header
      • containsKey

        public boolean containsKey​(String name)
        Check if a header is present
        Parameters:
        name - a header
        Returns:
        if the headers contain this name.
      • clear

        public void clear()
        Clear the headers!
      • getFirst

        public String getFirst​(String key)
        Get the first header value for a name
        Parameters:
        key - the name of the header
        Returns:
        the first value
      • all

        public List<Header> all()
        Get all of the headers
        Returns:
        all the headers, in order
      • toString

        public String toString()
        Overrides:
        toString in class Object
        Returns:
        list all headers like this:
        Content-Length: 42
         Cache-Control: no-cache
         ...
      • cookie

        public void cookie​(Cookie cookie)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • setBasicAuth

        public void setBasicAuth​(String username,
                                 String password)
      • accepts

        public void accepts​(String value)
      • replace

        public void replace​(Map<String,​String> headerMap)
        Replace all headers from a given map.
        Parameters:
        headerMap - the map of headers