Class Headers
java.lang.Object
kong.unirest.core.Headers
Represents a collection of headers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsets the Accept headervoidAdd a header elementvoidAdd a header element with a supplier which will be evaluated on requestvoidSets headers based on a map of key-value pairsall()Get all of the headersvoidclear()Clear the headers!booleancontainsKey(String name) Check if a header is presentvoidcookie(Collection<Cookie> cookies) sets a collection of cookiesvoidAdd a Cookie headerbooleanGet all the values for a header nameGet the first header value for a nameinthashCode()voidAdd a bunch of headers at oncevoidRemove a header by namevoidReplace a header value.voidReplace all headers from a given map.voidsetBasicAuth(String username, String password) creates a basic auth header from a username and password.intsize()Get the number of header keys.toString()
-
Constructor Details
-
Headers
public Headers() -
Headers
-
-
Method Details
-
add
-
add
-
replace
-
remove
-
size
public int size()Get the number of header keys.- Returns:
- the size of the header keys
-
get
-
putAll
-
containsKey
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
-
all
-
cookie
-
cookie
sets a collection of cookies- Parameters:
cookies- some cookies
-
toString
-
equals
-
hashCode
-
setBasicAuth
creates a basic auth header from a username and password. The creds will be the Base64 encoded value of {username}:{password} along with the 'Basic' schema For example given a creds of "username" and "password" you would get eg: Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=- Parameters:
username- the usernamepassword- the password
-
accepts
-
add
-
replace
-