Package kong.unirest.core
Class Headers
- java.lang.Object
-
- kong.unirest.core.Headers
-
public class Headers extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classHeaders.Entry
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Header>headersprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description Headers()Headers(java.util.Collection<Headers.Entry> entries)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccepts(java.lang.String value)voidadd(java.lang.String name, java.lang.String value)Add a header elementvoidadd(java.lang.String name, java.util.function.Supplier<java.lang.String> value)Add a header element with a supplier which will be evaluated on requestvoidadd(java.util.Map<java.lang.String,java.lang.String> headerMap)java.util.List<Header>all()Get all of the headersvoidclear()Clear the headers!booleancontainsKey(java.lang.String name)Check if a header is presentvoidcookie(java.util.Collection<Cookie> cookies)voidcookie(Cookie cookie)booleanequals(java.lang.Object o)java.util.List<java.lang.String>get(java.lang.String name)Get all the values for a header namejava.lang.StringgetFirst(java.lang.String key)Get the first header value for a nameinthashCode()private booleanisName(Header h, java.lang.String name)voidputAll(Headers header)Add a bunch of headers at oncevoidremove(java.lang.String name)Remove a header by name(package private) voidremove(java.lang.String key, java.lang.String value)voidreplace(java.lang.String name, java.lang.String value)Replace a header value.voidreplace(java.util.Map<java.lang.String,java.lang.String> headerMap)Replace all headers from a given map.voidsetBasicAuth(java.lang.String username, java.lang.String password)intsize()Get the number of header keys.java.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
headers
private java.util.List<Header> headers
-
-
Constructor Detail
-
Headers
public Headers()
-
Headers
public Headers(java.util.Collection<Headers.Entry> entries)
-
-
Method Detail
-
add
public void add(java.lang.String name, java.lang.String value)Add a header element- Parameters:
name- the name of the headervalue- the value for the header
-
add
public void add(java.lang.String name, java.util.function.Supplier<java.lang.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(java.lang.String name, java.lang.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
-
remove
public void remove(java.lang.String name)
Remove a header by name- Parameters:
name- the name of the header
-
size
public int size()
Get the number of header keys.- Returns:
- the size of the header keys
-
get
public java.util.List<java.lang.String> get(java.lang.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(java.lang.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 java.lang.String getFirst(java.lang.String key)
Get the first header value for a name- Parameters:
key- the name of the header- Returns:
- the first value
-
all
public java.util.List<Header> all()
Get all of the headers- Returns:
- all the headers, in order
-
isName
private boolean isName(Header h, java.lang.String name)
-
remove
void remove(java.lang.String key, java.lang.String value)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- list all headers like this:
Content-Length: 42 Cache-Control: no-cache ...
-
cookie
public void cookie(Cookie cookie)
-
cookie
public void cookie(java.util.Collection<Cookie> cookies)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
setBasicAuth
public void setBasicAuth(java.lang.String username, java.lang.String password)
-
accepts
public void accepts(java.lang.String value)
-
add
public void add(java.util.Map<java.lang.String,java.lang.String> headerMap)
-
replace
public void replace(java.util.Map<java.lang.String,java.lang.String> headerMap)
Replace all headers from a given map.- Parameters:
headerMap- the map of headers
-
-