public final class EmptyHttpHeaders extends 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(CharSequence name,
CharSequence... values)
Adds new headers with the specified
name and values. |
HttpHeaders |
add(CharSequence name,
CharSequence value)
Adds a new header with the specified
name and value. |
HttpHeaders |
add(CharSequence name,
Iterable<? extends CharSequence> values)
Adds new headers with the specified
name and values. |
HttpHeaders |
add(CharSequence name,
Iterator<? extends CharSequence> valuesItr)
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(CharSequence name,
CharSequence value)
|
HttpHeaders |
addCookie(HttpCookiePair cookie)
Adds a cookie.
|
HttpHeaders |
addSetCookie(CharSequence name,
CharSequence value)
|
HttpHeaders |
addSetCookie(HttpSetCookie cookie)
Adds a set-cookie.
|
HttpHeaders |
clear()
Removes all headers.
|
boolean |
contains(CharSequence name)
Returns
true if a header with the name exists, false otherwise. |
boolean |
contains(CharSequence name,
CharSequence value)
Returns
true if a header with the name and value exists, false otherwise. |
boolean |
containsIgnoreCase(CharSequence name,
CharSequence value)
Returns
true if a header with the name and value exists, false otherwise. |
boolean |
equals(Object o) |
void |
forEach(Consumer<? super Map.Entry<CharSequence,CharSequence>> action) |
CharSequence |
get(CharSequence name)
Returns the value of a header with the specified name.
|
CharSequence |
get(CharSequence name,
CharSequence defaultValue)
Returns the value of a header with the specified name.
|
CharSequence |
getAndRemove(CharSequence name)
Returns the value of a header with the specified name and removes it from this object.
|
CharSequence |
getAndRemove(CharSequence name,
CharSequence defaultValue)
Returns the value of a header with the specified name and removes it from this object.
|
HttpCookiePair |
getCookie(CharSequence name)
Gets a cookie identified by
name. |
Iterable<? extends HttpCookiePair> |
getCookies()
Gets all the cookies.
|
Iterable<? extends HttpCookiePair> |
getCookies(CharSequence name)
Gets the cookies with the same name.
|
Iterator<? extends HttpCookiePair> |
getCookiesIterator()
Gets all the cookies.
|
Iterator<? extends HttpCookiePair> |
getCookiesIterator(CharSequence name)
Gets the cookies with the same name.
|
HttpSetCookie |
getSetCookie(CharSequence name)
Gets a set-cookie identified by
name. |
Iterable<? extends HttpSetCookie> |
getSetCookies()
Gets all the set-cookies.
|
Iterable<? extends HttpSetCookie> |
getSetCookies(CharSequence name)
Gets the set-cookies with the same name.
|
Iterable<? extends HttpSetCookie> |
getSetCookies(CharSequence name,
CharSequence domain,
CharSequence path)
Gets the set-cookies with the same name.
|
Iterator<? extends HttpSetCookie> |
getSetCookiesIterator()
Gets all the set-cookies.
|
Iterator<? extends HttpSetCookie> |
getSetCookiesIterator(CharSequence name)
Gets the set-cookies with the same name.
|
Iterator<? extends HttpSetCookie> |
getSetCookiesIterator(CharSequence name,
CharSequence domain,
CharSequence path)
Gets the set-cookies with the same name.
|
int |
hashCode() |
boolean |
isEmpty()
|
Iterator<Map.Entry<CharSequence,CharSequence>> |
iterator() |
Set<? extends CharSequence> |
names()
Returns a
Set of all header names in this object. |
boolean |
remove(CharSequence name)
Removes all headers with the specified
name. |
boolean |
remove(CharSequence name,
CharSequence value)
Removes specific value(s) from the specified header
name. |
boolean |
removeCookies(CharSequence name)
Removes all cookie identified by
name. |
boolean |
removeIgnoreCase(CharSequence name,
CharSequence value)
Removes specific value(s) from the specified header
name. |
boolean |
removeSetCookies(CharSequence name)
Removes all set-cookie identified by
name. |
boolean |
removeSetCookies(CharSequence name,
CharSequence domain,
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(CharSequence name,
CharSequence... values)
Sets a header with the specified
name and values. |
HttpHeaders |
set(CharSequence name,
CharSequence value)
Sets a header with the specified
name and value. |
HttpHeaders |
set(CharSequence name,
Iterable<? extends CharSequence> values)
Sets a new header with the specified
name and values. |
HttpHeaders |
set(CharSequence name,
Iterator<? extends CharSequence> valueItr)
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.
|
Spliterator<Map.Entry<CharSequence,CharSequence>> |
spliterator() |
String |
toString()
Returns a
String representation of this HttpHeaders. |
String |
toString(BiFunction<? super CharSequence,? super CharSequence,CharSequence> filter)
Builds a string which represents all the content in this
HttpHeaders in which sensitive headers can be
filtered via filter. |
Iterable<? extends CharSequence> |
values(CharSequence name)
Returns all values for the header with the specified name.
|
Iterator<? extends CharSequence> |
valuesIterator(CharSequence name)
Returns all values for the header with the specified name.
|
public static final HttpHeaders INSTANCE
@Nullable public CharSequence get(CharSequence name)
HttpHeadersget in interface HttpHeadersname - the name of the header to retrieve.null if there's no such header.public CharSequence get(CharSequence name,
CharSequence defaultValue)
HttpHeadersget in interface HttpHeadersname - the name of the header to retrieve.defaultValue - the default value.defaultValue if there is no such header.@Nullable public CharSequence getAndRemove(CharSequence name)
HttpHeadersgetAndRemove in interface HttpHeadersname - the name of the header to retrieve.null if there is no such header.public CharSequence getAndRemove(CharSequence name,
CharSequence defaultValue)
HttpHeadersgetAndRemove in interface HttpHeadersname - the name of the header to retrieve.defaultValue - the default value.defaultValue if there is no such header.public Iterable<? extends CharSequence> values(CharSequence name)
HttpHeadersvalues in interface HttpHeadersname - the name of the header to retrieve.Iterable of header values or an empty Iterable if no values are found.if minimal object allocation is required.public Iterator<? extends CharSequence> valuesIterator(CharSequence name)
HttpHeadersvaluesIterator in interface HttpHeadersname - 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(CharSequence name)
HttpHeaderstrue if a header with the name exists, false otherwise.contains in interface HttpHeadersname - the header name.true if name exists.public boolean contains(CharSequence name,
CharSequence value)
HttpHeaderstrue if a header with the name and value exists, false otherwise.contains in interface HttpHeadersname - the header name.value - the header value of the header to find.true if a name, value pair exists.public boolean containsIgnoreCase(CharSequence name,
CharSequence value)
HttpHeaderstrue if a header with the name and value exists, false otherwise.
Case insensitive compare is done on the value.
containsIgnoreCase in interface HttpHeadersname - the name of the header to find.value - the value of the header to find.true if found.public int size()
HttpHeaderssize in interface HttpHeaderspublic boolean isEmpty()
HttpHeadersisEmpty in interface HttpHeaderstrue if HttpHeaders.size() equals 0.public Set<? extends CharSequence> names()
HttpHeadersSet of all header names in this object. The returned Set cannot be modified.names in interface HttpHeadersSet of all header names in this object. The returned Set cannot be modified.public HttpHeaders add(CharSequence name, CharSequence value)
HttpHeadersname and value.add in interface HttpHeadersname - the name of the header.value - the value of the header.this.public HttpHeaders add(CharSequence name, Iterable<? extends CharSequence> values)
HttpHeadersname and values. This method is semantically equivalent to:
for (T value : values) {
headers.add(name, value);
}
add in interface HttpHeadersname - the name of the header.values - the values of the header.this.public HttpHeaders add(CharSequence name, Iterator<? extends CharSequence> valuesItr)
HttpHeadersname and values. This method is semantically equivalent to:
while (valueItr.hasNext()) {
headers.add(name, valueItr.next());
}
add in interface HttpHeadersname - the name of the header.valuesItr - the values of the header.this.public HttpHeaders add(CharSequence name, CharSequence... values)
HttpHeadersname and values. This method is semantically equivalent to:
for (T value : values) {
headers.add(name, value);
}
add in interface HttpHeadersname - the name of the header.values - the values of the header.this.public HttpHeaders add(HttpHeaders headers)
HttpHeadersheaders to this object.add in interface HttpHeadersheaders - the headers to add.this.public HttpHeaders set(CharSequence name, CharSequence value)
HttpHeadersname and value. Any existing headers with the same name are
overwritten.set in interface HttpHeadersname - the name of the header.value - the value of the header.this.public HttpHeaders set(CharSequence name, Iterable<? extends CharSequence> values)
HttpHeadersname and values. This method is equivalent to:
headers.remove(name);
for (T value : values) {
headers.add(name, value);
}
set in interface HttpHeadersname - the name of the header.values - the values of the header.this.public HttpHeaders set(CharSequence name, Iterator<? extends CharSequence> valueItr)
HttpHeadersname and values. This method is equivalent to:
headers.remove(name);
while (valueItr.hasNext()) {
headers.add(name, valueItr.next());
}
set in interface HttpHeadersname - the name of the header.valueItr - the values of the header.this.public HttpHeaders set(CharSequence name, CharSequence... values)
HttpHeadersname 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 HttpHeadersname - the name of the header.values - the values of the header.this.public HttpHeaders set(HttpHeaders headers)
HttpHeadersheaders object.set in interface HttpHeadersheaders - the headers object which contains new values.this.public HttpHeaders replace(HttpHeaders headers)
HttpHeadersheaders from this object, and then adds all headers contained in
headers.replace in interface HttpHeadersheaders - the headers used to remove names and then add new entries.this.public boolean remove(CharSequence name)
HttpHeadersname.remove in interface HttpHeadersname - the name of the header.true if at least one entry has been removed.public boolean remove(CharSequence name,
CharSequence value)
HttpHeadersname. If the header has more than one identical
values, all of them will be removed.remove in interface HttpHeadersname - 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(CharSequence name,
CharSequence value)
HttpHeadersname. 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 HttpHeadersname - 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()
HttpHeadersclear in interface HttpHeadersthis.public Iterator<Map.Entry<CharSequence,CharSequence>> iterator()
iterator in interface HttpHeadersiterator in interface Iterable<Map.Entry<CharSequence,CharSequence>>public Spliterator<Map.Entry<CharSequence,CharSequence>> spliterator()
spliterator in interface HttpHeadersspliterator in interface Iterable<Map.Entry<CharSequence,CharSequence>>public void forEach(Consumer<? super Map.Entry<CharSequence,CharSequence>> action)
forEach in interface Iterable<Map.Entry<CharSequence,CharSequence>>public boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
HttpHeadersString 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 HttpHeaderstoString in class ObjectString representation of this HttpHeaders.public String toString(BiFunction<? super CharSequence,? super CharSequence,CharSequence> filter)
HttpHeadersHttpHeaders in which sensitive headers can be
filtered via filter.toString in interface HttpHeadersfilter - a function that accepts the header name and value and returns the filtered value.HttpHeaders.@Nullable public HttpCookiePair getCookie(CharSequence name)
HttpHeadersname. If there
is more than one HttpSetCookie for the specified name, the first HttpSetCookie in insertion order
is returned.getCookie in interface HttpHeadersname - the cookie-name to look for.HttpSetCookie identified by name.@Nullable public HttpSetCookie getSetCookie(CharSequence name)
HttpHeadersname. If
there is more than one HttpSetCookie for the specified name, the first HttpSetCookie in insertion
order is returned.getSetCookie in interface HttpHeadersname - the cookie-name to look for.HttpSetCookie identified by name.public Iterable<? extends HttpCookiePair> getCookies()
HttpHeadersgetCookies in interface HttpHeadersIterable with all the cookies.if minimal object allocation is required.public Iterator<? extends HttpCookiePair> getCookiesIterator()
HttpHeadersgetCookiesIterator in interface HttpHeadersIterator with all the cookies.if Iterable is preferred, at the expense of more object allocation.public Iterable<? extends HttpCookiePair> getCookies(CharSequence name)
HttpHeadersgetCookies in interface HttpHeadersname - the cookie-name of the HttpSetCookies to get.Iterable where all the HttpSetCookies have the same name.if minimal object allocation is required.public Iterator<? extends HttpCookiePair> getCookiesIterator(CharSequence name)
HttpHeadersgetCookiesIterator in interface HttpHeadersname - the cookie-name of the HttpSetCookies to get.Iterator where all the HttpSetCookies have the same name.if Iterable is preferred, at the expense of more object allocation.public Iterable<? extends HttpSetCookie> getSetCookies()
HttpHeadersgetSetCookies in interface HttpHeadersIterable with all the
set-cookies.if minimal object allocation is required.public Iterator<? extends HttpSetCookie> getSetCookiesIterator()
HttpHeadersgetSetCookiesIterator in interface HttpHeadersIterator with all the
set-cookies.if Iterable is preferred, at the expense of more object allocation.public Iterable<? extends HttpSetCookie> getSetCookies(CharSequence name)
HttpHeadersgetSetCookies in interface HttpHeadersname - the cookie-name of the HttpSetCookies to get.Iterable where all the HttpSetCookies have the same name.if minimal object allocation is required.public Iterator<? extends HttpSetCookie> getSetCookiesIterator(CharSequence name)
HttpHeadersgetSetCookiesIterator in interface HttpHeadersname - the cookie-name of the HttpSetCookies to get.Iterator where all the HttpSetCookies have the same name.if Iterable is preferred, at the expense of more object allocation.public Iterable<? extends HttpSetCookie> getSetCookies(CharSequence name, CharSequence domain, CharSequence path)
HttpHeadersgetSetCookies in interface HttpHeadersname - the cookie-name of the HttpSetCookies to get.domain - the domain-value of the HttpSetCookies to get. This value may be matched according
to the Domain Matching algorithm.path - the path-av of the HttpSetCookies to get. This value may be matched according
to the Path Matching algorithm.Iterable where all the HttpSetCookies match the parameter values.if minimal object allocation is required.public Iterator<? extends HttpSetCookie> getSetCookiesIterator(CharSequence name, CharSequence domain, CharSequence path)
HttpHeadersgetSetCookiesIterator in interface HttpHeadersname - the cookie-name of the HttpSetCookies to get.domain - the domain-value of the HttpSetCookies to get. This value may be matched according
to the Domain Matching algorithm.path - the path-av of the HttpSetCookies to get. This value may be matched according
to the Path Matching algorithm.Iterator where all the HttpSetCookies 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 HttpCookiePairs with same name.
addCookie in interface HttpHeaderscookie - the cookie to add.this.public HttpHeaders addCookie(CharSequence name, CharSequence value)
HttpHeadersname and
value.
This may result in multiple HttpSetCookies with same name. Added cookie will not be wrapped, not secure,
and not HTTP-only, with no path, domain, expire date and maximum age.
addCookie in interface HttpHeadersname - the name of the cookie.value - the value of the cookie.this.public HttpHeaders addSetCookie(HttpSetCookie cookie)
HttpHeaders
This may result in multiple HttpSetCookies with same name.
addSetCookie in interface HttpHeaderscookie - the cookie to add.this.public HttpHeaders addSetCookie(CharSequence name, CharSequence value)
HttpHeadersname
and value.
This may result in multiple HttpSetCookies with same name. Added cookie will not be wrapped, not secure,
and not HTTP-only, with no path, domain, expire date and maximum age.
addSetCookie in interface HttpHeadersname - the name of the cookie.value - the value of the cookie.this.public boolean removeCookies(CharSequence name)
HttpHeadersname.removeCookies in interface HttpHeadersname - the cookie-name of the HttpSetCookies to remove.true if at least one entry has been removed.public boolean removeSetCookies(CharSequence name)
HttpHeadersname.removeSetCookies in interface HttpHeadersname - the cookie-name of the HttpSetCookies to remove.true if at least one entry has been removed.public boolean removeSetCookies(CharSequence name,
CharSequence domain,
CharSequence path)
HttpHeadersname.removeSetCookies in interface HttpHeadersname - the cookie-name of the HttpSetCookies to remove.domain - the domain-value of the HttpSetCookies to remove. This value may be matched according
to the Domain Matching algorithm.path - the path-av of the HttpSetCookies to remove. This value may be matched according
to the Path Matching algorithm.true if at least one entry has been removed.