Class Headers

java.lang.Object
kong.unirest.core.Headers

public class Headers extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • 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
    • remove

      private void remove(String name)
    • 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
    • isName

      private boolean isName(Header h, String name)
    • remove

      void remove(String key, String value)
    • 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)
    • cookie

      public void cookie(Collection<Cookie> cookies)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

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

      public void accepts(String value)
    • add

      public void add(Map<String,String> headerMap)
    • replace

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