public final class EmptyHttpHeaders extends java.lang.Object implements HttpHeaders
HttpHeaders
which are always empty and does not allow modification.Modifier and Type | Field and Description |
---|---|
static HttpHeaders |
INSTANCE |
Modifier and Type | Method and Description |
---|---|
HttpHeaders |
add(java.lang.CharSequence name,
java.lang.CharSequence... values)
Adds new headers with the specified
name and values . |
HttpHeaders |
add(java.lang.CharSequence name,
java.lang.CharSequence value)
Adds a new header with the specified
name and value . |
HttpHeaders |
add(java.lang.CharSequence name,
java.lang.Iterable<? extends java.lang.CharSequence> values)
Adds new headers with the specified
name and values . |
HttpHeaders |
add(HttpHeaders headers)
Adds all header names and values of
headers to this object. |
HttpHeaders |
addCookie(HttpCookiePair cookie)
Adds a cookie.
|
HttpHeaders |
addSetCookie(HttpSetCookie cookie)
Adds a set-cookie.
|
HttpHeaders |
clear()
Removes all headers.
|
boolean |
contains(java.lang.CharSequence name,
java.lang.CharSequence value)
Returns
true if a header with the name and value exists, false otherwise. |
boolean |
containsIgnoreCase(java.lang.CharSequence name,
java.lang.CharSequence value)
Returns
true if a header with the name and value exists, false otherwise. |
boolean |
equals(java.lang.Object o) |
java.lang.CharSequence |
get(java.lang.CharSequence name)
Returns the value of a header with the specified name.
|
java.lang.CharSequence |
get(java.lang.CharSequence name,
java.lang.CharSequence defaultValue)
Returns the value of a header with the specified name.
|
java.lang.CharSequence |
getAndRemove(java.lang.CharSequence name)
Returns the value of a header with the specified name and removes it from this object.
|
HttpCookiePair |
getCookie(java.lang.CharSequence name)
Gets a cookie identified by
name . |
java.util.Iterator<? extends HttpCookiePair> |
getCookiesIterator()
Gets all the cookies.
|
java.util.Iterator<? extends HttpCookiePair> |
getCookiesIterator(java.lang.CharSequence name)
Gets the cookies with the same name.
|
HttpSetCookie |
getSetCookie(java.lang.CharSequence name)
Gets a set-cookie identified by
name . |
java.util.Iterator<? extends HttpSetCookie> |
getSetCookiesIterator()
Gets all the set-cookies.
|
java.util.Iterator<? extends HttpSetCookie> |
getSetCookiesIterator(java.lang.CharSequence name)
Gets the set-cookies with the same name.
|
java.util.Iterator<? extends HttpSetCookie> |
getSetCookiesIterator(java.lang.CharSequence name,
java.lang.CharSequence domain,
java.lang.CharSequence path)
Gets the set-cookies with the same name.
|
int |
hashCode() |
boolean |
isEmpty()
|
java.util.Iterator<java.util.Map.Entry<java.lang.CharSequence,java.lang.CharSequence>> |
iterator() |
java.util.Set<? extends java.lang.CharSequence> |
names()
Returns a
Set of all header names in this object. |
boolean |
remove(java.lang.CharSequence name)
Removes all headers with the specified
name . |
boolean |
remove(java.lang.CharSequence name,
java.lang.CharSequence value)
Removes specific value(s) from the specified header
name . |
boolean |
removeCookies(java.lang.CharSequence name)
Removes all cookie identified by
name . |
boolean |
removeIgnoreCase(java.lang.CharSequence name,
java.lang.CharSequence value)
Removes specific value(s) from the specified header
name . |
boolean |
removeSetCookies(java.lang.CharSequence name)
Removes all set-cookie identified by
name . |
boolean |
removeSetCookies(java.lang.CharSequence name,
java.lang.CharSequence domain,
java.lang.CharSequence path)
Removes all set-cookie identified by
name . |
HttpHeaders |
replace(HttpHeaders headers)
Removes all header names contained in
headers from this object, and then adds all headers contained in
headers . |
HttpHeaders |
set(java.lang.CharSequence name,
java.lang.CharSequence... values)
Sets a header with the specified
name and values . |
HttpHeaders |
set(java.lang.CharSequence name,
java.lang.CharSequence value)
Sets a header with the specified
name and value . |
HttpHeaders |
set(java.lang.CharSequence name,
java.lang.Iterable<? extends java.lang.CharSequence> values)
Sets a new header with the specified
name and values . |
HttpHeaders |
set(HttpHeaders headers)
Clears the current header entries and copies all header entries of the specified
headers object. |
int |
size()
Returns the number of headers in this object.
|
java.lang.String |
toString()
Returns a
String representation of this HttpHeaders . |
java.lang.String |
toString(java.util.function.BiFunction<? super java.lang.CharSequence,? super java.lang.CharSequence,java.lang.CharSequence> filter)
Builds a string which represents all the content in this
HttpHeaders in which sensitive headers can be
filtered via filter . |
java.util.Iterator<? extends java.lang.CharSequence> |
valuesIterator(java.lang.CharSequence name)
Returns all values for the header with the specified name.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, addCookie, addSetCookie, contains, getAndRemove, getCookies, getCookies, getSetCookies, getSetCookies, getSetCookies, set, spliterator, values
public static final HttpHeaders INSTANCE
@Nullable public java.lang.CharSequence get(java.lang.CharSequence name)
HttpHeaders
get
in interface HttpHeaders
name
- the name of the header to retrieve.null
if there's no such header.public java.lang.CharSequence get(java.lang.CharSequence name, java.lang.CharSequence defaultValue)
HttpHeaders
get
in interface HttpHeaders
name
- the name of the header to retrieve.defaultValue
- the default value.defaultValue
if there is no such header.@Nullable public java.lang.CharSequence getAndRemove(java.lang.CharSequence name)
HttpHeaders
getAndRemove
in interface HttpHeaders
name
- the name of the header to retrieve.null
if there is no such header.public java.util.Iterator<? extends java.lang.CharSequence> valuesIterator(java.lang.CharSequence name)
HttpHeaders
valuesIterator
in interface HttpHeaders
name
- the name of the header to retrieve.Iterator
of header values or an empty Iterator
if no values are found.if Iterable is preferred, at the expense of more object allocation.
public boolean contains(java.lang.CharSequence name, java.lang.CharSequence value)
HttpHeaders
true
if a header with the name
and value
exists, false
otherwise.contains
in interface HttpHeaders
name
- the header name.value
- the header value of the header to find.true
if a name
, value
pair exists.public boolean containsIgnoreCase(java.lang.CharSequence name, java.lang.CharSequence value)
HttpHeaders
true
if a header with the name
and value
exists, false
otherwise.
Case insensitive compare is done on the value.
containsIgnoreCase
in interface HttpHeaders
name
- the name of the header to find.value
- the value of the header to find.true
if found.public int size()
HttpHeaders
size
in interface HttpHeaders
public boolean isEmpty()
HttpHeaders
isEmpty
in interface HttpHeaders
true
if HttpHeaders.size()
equals 0
.public java.util.Set<? extends java.lang.CharSequence> names()
HttpHeaders
Set
of all header names in this object. The returned Set
cannot be modified.names
in interface HttpHeaders
Set
of all header names in this object. The returned Set
cannot be modified.public HttpHeaders add(java.lang.CharSequence name, java.lang.CharSequence value)
HttpHeaders
name
and value
.add
in interface HttpHeaders
name
- the name of the header.value
- the value of the header.this
.public HttpHeaders add(java.lang.CharSequence name, java.lang.Iterable<? extends java.lang.CharSequence> values)
HttpHeaders
name
and values
. This method is semantically equivalent to:
for (T value : values) { headers.add(name, value); }
add
in interface HttpHeaders
name
- the name of the header.values
- the values of the header.this
.public HttpHeaders add(java.lang.CharSequence name, java.lang.CharSequence... values)
HttpHeaders
name
and values
. This method is semantically equivalent to:
for (T value : values) { headers.add(name, value); }
add
in interface HttpHeaders
name
- the name of the header.values
- the values of the header.this
.public HttpHeaders add(HttpHeaders headers)
HttpHeaders
headers
to this object.add
in interface HttpHeaders
headers
- the headers to add.this
.public HttpHeaders set(java.lang.CharSequence name, java.lang.CharSequence value)
HttpHeaders
name
and value
. Any existing headers with the same name are
overwritten.set
in interface HttpHeaders
name
- the name of the header.value
- the value of the header.this
.public HttpHeaders set(java.lang.CharSequence name, java.lang.Iterable<? extends java.lang.CharSequence> values)
HttpHeaders
name
and values
. This method is equivalent to:
headers.remove(name); for (T value : values) { headers.add(name, value); }
set
in interface HttpHeaders
name
- the name of the header.values
- the values of the header.this
.public HttpHeaders set(java.lang.CharSequence name, java.lang.CharSequence... values)
HttpHeaders
name
and values
. Any existing headers with this name are
removed. This method is equivalent to:
headers.remove(name); for (T value : values) { headers.add(name, value); }
set
in interface HttpHeaders
name
- the name of the header.values
- the values of the header.this
.public HttpHeaders set(HttpHeaders headers)
HttpHeaders
headers
object.set
in interface HttpHeaders
headers
- the headers object which contains new values.this
.public HttpHeaders replace(HttpHeaders headers)
HttpHeaders
headers
from this object, and then adds all headers contained in
headers
.replace
in interface HttpHeaders
headers
- the headers used to remove names and then add new entries.this
.public boolean remove(java.lang.CharSequence name)
HttpHeaders
name
.remove
in interface HttpHeaders
name
- the name of the header.true
if at least one entry has been removed.public boolean remove(java.lang.CharSequence name, java.lang.CharSequence value)
HttpHeaders
name
. If the header has more than one identical
values, all of them will be removed.remove
in interface HttpHeaders
name
- the name of the header.value
- the value of the header to remove.true
if at least one value has been removed.public boolean removeIgnoreCase(java.lang.CharSequence name, java.lang.CharSequence value)
HttpHeaders
name
. If the header has more than one identical
values, all of them will be removed.
Case insensitive compare is done on the value.
removeIgnoreCase
in interface HttpHeaders
name
- the name of the header.value
- the value of the header to remove.true
if at least one value has been removed.public HttpHeaders clear()
HttpHeaders
clear
in interface HttpHeaders
this
.public java.util.Iterator<java.util.Map.Entry<java.lang.CharSequence,java.lang.CharSequence>> iterator()
iterator
in interface HttpHeaders
iterator
in interface java.lang.Iterable<java.util.Map.Entry<java.lang.CharSequence,java.lang.CharSequence>>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
HttpHeaders
String
representation of this HttpHeaders
. To avoid accidentally logging sensitive
information, implementations should be cautious about logging header content and consider using
HttpHeaders.toString(BiFunction)
.toString
in interface HttpHeaders
toString
in class java.lang.Object
String
representation of this HttpHeaders
.public java.lang.String toString(java.util.function.BiFunction<? super java.lang.CharSequence,? super java.lang.CharSequence,java.lang.CharSequence> filter)
HttpHeaders
HttpHeaders
in which sensitive headers can be
filtered via filter
.toString
in interface HttpHeaders
filter
- a function that accepts the header name and value and returns the filtered value.HttpHeaders
.@Nullable public HttpCookiePair getCookie(java.lang.CharSequence name)
HttpHeaders
name
. If there
is more than one HttpSetCookie
for the specified name, the first HttpSetCookie
in insertion order
is returned.getCookie
in interface HttpHeaders
name
- the cookie-name to look for.HttpSetCookie
identified by name
.@Nullable public HttpSetCookie getSetCookie(java.lang.CharSequence name)
HttpHeaders
name
. If
there is more than one HttpSetCookie
for the specified name, the first HttpSetCookie
in insertion
order is returned.getSetCookie
in interface HttpHeaders
name
- the cookie-name to look for.HttpSetCookie
identified by name
.public java.util.Iterator<? extends HttpCookiePair> getCookiesIterator()
HttpHeaders
getCookiesIterator
in interface HttpHeaders
Iterator
with all the cookies.if Iterable is preferred, at the expense of more object allocation.
public java.util.Iterator<? extends HttpCookiePair> getCookiesIterator(java.lang.CharSequence name)
HttpHeaders
getCookiesIterator
in interface HttpHeaders
name
- the cookie-name of the HttpSetCookie
s to get.Iterator
where all the HttpSetCookie
s have the same name.if Iterable is preferred, at the expense of more object allocation.
public java.util.Iterator<? extends HttpSetCookie> getSetCookiesIterator()
HttpHeaders
getSetCookiesIterator
in interface HttpHeaders
Iterator
with all the
set-cookies.if Iterable is preferred, at the expense of more object allocation.
public java.util.Iterator<? extends HttpSetCookie> getSetCookiesIterator(java.lang.CharSequence name)
HttpHeaders
getSetCookiesIterator
in interface HttpHeaders
name
- the cookie-name of the HttpSetCookie
s to get.Iterator
where all the HttpSetCookie
s have the same name.if Iterable is preferred, at the expense of more object allocation.
public java.util.Iterator<? extends HttpSetCookie> getSetCookiesIterator(java.lang.CharSequence name, java.lang.CharSequence domain, java.lang.CharSequence path)
HttpHeaders
getSetCookiesIterator
in interface HttpHeaders
name
- the cookie-name of the HttpSetCookie
s to get.domain
- the domain-value of the HttpSetCookie
s to get. This value may be matched according
to the Domain Matching algorithm.path
- the path-av of the HttpSetCookie
s to get. This value may be matched according
to the Path Matching algorithm.Iterator
where all the HttpSetCookie
s match the parameter values.if Iterable is preferred, at the expense of more
object allocation.
public HttpHeaders addCookie(HttpCookiePair cookie)
HttpHeaders
This may result in multiple HttpCookiePair
s with same name.
addCookie
in interface HttpHeaders
cookie
- the cookie to add.this
.public HttpHeaders addSetCookie(HttpSetCookie cookie)
HttpHeaders
This may result in multiple HttpSetCookie
s with same name.
addSetCookie
in interface HttpHeaders
cookie
- the cookie to add.this
.public boolean removeCookies(java.lang.CharSequence name)
HttpHeaders
name
.removeCookies
in interface HttpHeaders
name
- the cookie-name of the HttpSetCookie
s to remove.true
if at least one entry has been removed.public boolean removeSetCookies(java.lang.CharSequence name)
HttpHeaders
name
.removeSetCookies
in interface HttpHeaders
name
- the cookie-name of the HttpSetCookie
s to remove.true
if at least one entry has been removed.public boolean removeSetCookies(java.lang.CharSequence name, java.lang.CharSequence domain, java.lang.CharSequence path)
HttpHeaders
name
.removeSetCookies
in interface HttpHeaders
name
- the cookie-name of the HttpSetCookie
s to remove.domain
- the domain-value of the HttpSetCookie
s to remove. This value may be matched according
to the Domain Matching algorithm.path
- the path-av of the HttpSetCookie
s to remove. This value may be matched according
to the Path Matching algorithm.true
if at least one entry has been removed.