Package kong.unirest.core
Class Headers
- java.lang.Object
-
- kong.unirest.core.Headers
-
public class Headers extends Object
-
-
Constructor Summary
Constructors Constructor Description Headers()
Headers(Collection<kong.unirest.core.Headers.Entry> entries)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accepts(String value)
void
add(String name, String value)
Add a header elementvoid
add(String name, Supplier<String> value)
Add a header element with a supplier which will be evaluated on requestvoid
add(Map<String,String> headerMap)
List<Header>
all()
Get all of the headersvoid
clear()
Clear the headers!boolean
containsKey(String name)
Check if a header is presentvoid
cookie(Collection<Cookie> cookies)
void
cookie(Cookie cookie)
boolean
equals(Object o)
List<String>
get(String name)
Get all the values for a header nameString
getFirst(String key)
Get the first header value for a nameint
hashCode()
void
putAll(Headers header)
Add a bunch of headers at oncevoid
replace(String name, String value)
Replace a header value.void
replace(Map<String,String> headerMap)
Replace all headers from a given map.void
setBasicAuth(String username, String password)
int
size()
Get the number of header keys.String
toString()
-
-
-
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 headervalue
- 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 headervalue
- 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 headervalue
- 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
-
toString
public String toString()
-
cookie
public void cookie(Cookie cookie)
-
cookie
public void cookie(Collection<Cookie> cookies)
-
accepts
public void accepts(String value)
-
-