public interface HttpHeadersBuilder
HttpHeaders.HttpHeaders.builder(),
HttpHeaders.toBuilder()| Modifier and Type | Method and Description |
|---|---|
HttpHeadersBuilder |
add(CharSequence name,
Iterable<String> values)
Adds new headers with the specified
name and values. |
HttpHeadersBuilder |
add(CharSequence name,
String... values)
Adds new headers with the specified
name and values. |
HttpHeadersBuilder |
add(CharSequence name,
String value)
Adds a new header with the specified
name and value. |
HttpHeadersBuilder |
add(Iterable<? extends Map.Entry<? extends CharSequence,String>> entries)
Adds all header names and values of the specified
entries. |
HttpHeadersBuilder |
addDouble(CharSequence name,
double value)
Adds a new header.
|
HttpHeadersBuilder |
addFloat(CharSequence name,
float value)
Adds a new header.
|
HttpHeadersBuilder |
addInt(CharSequence name,
int value)
Adds a new header.
|
HttpHeadersBuilder |
addLong(CharSequence name,
long value)
Adds a new header.
|
HttpHeadersBuilder |
addObject(CharSequence name,
Iterable<?> values)
Adds a new header with the specified name and values.
|
HttpHeadersBuilder |
addObject(CharSequence name,
Object... values)
Adds a new header with the specified name and values.
|
HttpHeadersBuilder |
addObject(CharSequence name,
Object value)
Adds a new header.
|
HttpHeadersBuilder |
addObject(Iterable<? extends Map.Entry<? extends CharSequence,?>> entries)
Adds all header names and values of the specified
entries. |
HttpHeadersBuilder |
addTimeMillis(CharSequence name,
long value)
Adds a new header.
|
HttpHeaders |
build()
Returns a newly created
HttpHeaders with the entries in this builder. |
HttpHeadersBuilder |
clear()
Removes all headers.
|
boolean |
contains(CharSequence name)
Returns
true if a header with the name exists, false otherwise. |
boolean |
contains(CharSequence name,
String value)
Returns
true if a header with the name and value exists. |
boolean |
containsDouble(CharSequence name,
double value)
Returns
true if a header with the name and value exists. |
boolean |
containsFloat(CharSequence name,
float value)
Returns
true if a header with the name and value exists. |
boolean |
containsInt(CharSequence name,
int value)
Returns
true if a header with the name and value exists. |
boolean |
containsLong(CharSequence name,
long value)
Returns
true if a header with the name and value exists. |
boolean |
containsObject(CharSequence name,
Object value)
Returns
true if a header with the name and value exists. |
boolean |
containsTimeMillis(CharSequence name,
long value)
Returns
true if a header with the name and value exists. |
MediaType |
contentType()
Returns the parsed
"content-type" header. |
HttpHeadersBuilder |
contentType(MediaType contentType)
Sets the
"content-type" header. |
HttpHeadersBuilder |
endOfStream(boolean endOfStream)
Sets whether the headers will be the last frame in an HTTP/2 stream.
|
void |
forEach(BiConsumer<io.netty.util.AsciiString,String> action)
Invokes the specified
action for all header entries. |
void |
forEachValue(CharSequence name,
Consumer<String> action)
Invokes the specified
action for all values of the headers with the specified name. |
String |
get(CharSequence name)
Returns the value of a header with the specified
name. |
String |
get(CharSequence name,
String defaultValue)
Returns the value of a header with the specified
name. |
List<String> |
getAll(CharSequence name)
Returns all values for the header with the specified name.
|
List<String> |
getAllAndRemove(CharSequence name)
Removes all the headers with the specified name and returns the removed header values.
|
String |
getAndRemove(CharSequence name)
Removes all the headers with the specified name and returns the header value which was added first.
|
String |
getAndRemove(CharSequence name,
String defaultValue)
Removes all the headers with the specified name and returns the header value which was added first.
|
Double |
getDouble(CharSequence name)
Returns the
double value of a header with the specified name. |
double |
getDouble(CharSequence name,
double defaultValue)
Returns the
double value of a header with the specified name. |
Double |
getDoubleAndRemove(CharSequence name)
Removes all the headers with the specified name and returns the header value which was added first.
|
double |
getDoubleAndRemove(CharSequence name,
double defaultValue)
Removes all the headers with the specified name and returns the header value which was added first.
|
Float |
getFloat(CharSequence name)
Returns the
float value of a header with the specified name. |
float |
getFloat(CharSequence name,
float defaultValue)
Returns the
float value of a header with the specified name. |
Float |
getFloatAndRemove(CharSequence name)
Removes all the headers with the specified name and returns the header value which was added first.
|
float |
getFloatAndRemove(CharSequence name,
float defaultValue)
Removes all the headers with the specified name and returns the header value which was added first.
|
Integer |
getInt(CharSequence name)
Returns the
int value of a header with the specified name. |
int |
getInt(CharSequence name,
int defaultValue)
Returns the
int value of a header with the specified name. |
Integer |
getIntAndRemove(CharSequence name)
Removes all the headers with the specified name and returns the header value which was added first.
|
int |
getIntAndRemove(CharSequence name,
int defaultValue)
Removes all the headers with the specified name and returns the header value which was added first.
|
Long |
getLong(CharSequence name)
Returns the
long value of a header with the specified name. |
long |
getLong(CharSequence name,
long defaultValue)
Returns the
long value of a header with the specified name. |
Long |
getLongAndRemove(CharSequence name)
Removes all the headers with the specified name and returns the header value which was added first.
|
long |
getLongAndRemove(CharSequence name,
long defaultValue)
Removes all the headers with the specified name and returns the header value which was added first.
|
Long |
getTimeMillis(CharSequence name)
Returns the value of a header with the specified
name in milliseconds. |
long |
getTimeMillis(CharSequence name,
long defaultValue)
Returns the value of a header with the specified
name in milliseconds. |
Long |
getTimeMillisAndRemove(CharSequence name)
Removes all the headers with the specified name and returns the header value which was added first.
|
long |
getTimeMillisAndRemove(CharSequence name,
long defaultValue)
Removes all the headers with the specified name and returns the header value which was added first.
|
boolean |
isEmpty()
Returns
true if this headers does not contain any entries. |
boolean |
isEndOfStream()
Tells whether the headers correspond to the last frame in an HTTP/2 stream.
|
Iterator<Map.Entry<io.netty.util.AsciiString,String>> |
iterator()
Returns an
Iterator that yields all header entries. |
Set<io.netty.util.AsciiString> |
names()
Returns a
Set of all header names. |
boolean |
remove(CharSequence name)
Removes all headers with the specified
name. |
HttpHeadersBuilder |
removeAndThen(CharSequence name)
Removes all headers with the specified
name. |
HttpHeadersBuilder |
set(CharSequence name,
Iterable<String> values)
Sets a new header with the specified name and values.
|
HttpHeadersBuilder |
set(CharSequence name,
String... values)
Sets a header with the specified name and values.
|
HttpHeadersBuilder |
set(CharSequence name,
String value)
Sets a header with the specified name and value.
|
HttpHeadersBuilder |
set(Iterable<? extends Map.Entry<? extends CharSequence,String>> entries)
Retains all current headers but calls
set(CharSequence, String) for each header in
the specified entries. |
HttpHeadersBuilder |
setDouble(CharSequence name,
double value)
Sets a header with the specified
name to value. |
HttpHeadersBuilder |
setFloat(CharSequence name,
float value)
Sets a header with the specified
name to value. |
HttpHeadersBuilder |
setIfAbsent(Iterable<? extends Map.Entry<? extends CharSequence,String>> entries)
Copies the entries missing in this headers from the specified
entries. |
HttpHeadersBuilder |
setInt(CharSequence name,
int value)
Sets a header with the specified
name to value. |
HttpHeadersBuilder |
setLong(CharSequence name,
long value)
Sets a header with the specified
name to value. |
HttpHeadersBuilder |
setObject(CharSequence name,
Iterable<?> values)
Sets a header with the specified name and values.
|
HttpHeadersBuilder |
setObject(CharSequence name,
Object... values)
Sets a header with the specified name and values.
|
HttpHeadersBuilder |
setObject(CharSequence name,
Object value)
Sets a new header.
|
HttpHeadersBuilder |
setObject(Iterable<? extends Map.Entry<? extends CharSequence,?>> entries)
Retains all current headers but calls
setObject(CharSequence, Object) for each entry in
the specified entries. |
HttpHeadersBuilder |
setTimeMillis(CharSequence name,
long value)
Sets a header with the specified
name to value. |
int |
size()
Returns the number of headers.
|
HttpHeadersBuilder |
sizeHint(int sizeHint)
Specifies the hint about the number of headers which may improve the memory efficiency and performance
of the underlying data structure.
|
default Stream<Map.Entry<io.netty.util.AsciiString,String>> |
stream()
Returns a
Stream that yields all header entries. |
Iterator<String> |
valueIterator(CharSequence name)
Returns an
Iterator that yields all values of the headers with the specified name. |
default Stream<String> |
valueStream(CharSequence name)
Returns a
Stream that yields all values of the headers with the specified name. |
forEach, spliteratorHttpHeaders build()
HttpHeaders with the entries in this builder.HttpHeadersBuilder sizeHint(int sizeHint)
thisIllegalStateException - if the hint was specified too late after the underlying data structure
has been fully initialized.HttpHeadersBuilder endOfStream(boolean endOfStream)
HttpHeadersBuilder contentType(MediaType contentType)
"content-type" header.String getAndRemove(CharSequence name)
name - the header namenull if there is no such headerString getAndRemove(CharSequence name, String defaultValue)
name - the header namedefaultValue - the default valuedefaultValue if there is no such headerList<String> getAllAndRemove(CharSequence name)
Integer getIntAndRemove(CharSequence name)
name - the header nameint value of the first value in insertion order or null if there is no
such value or it can't be converted into int.int getIntAndRemove(CharSequence name, int defaultValue)
name - the header namedefaultValue - the default valueint value of the first value in insertion order or defaultValue if there is
no such value or it can't be converted into int.Long getLongAndRemove(CharSequence name)
name - the header namelong value of the first value in insertion order or null if there is no such
value or it can't be converted into long.long getLongAndRemove(CharSequence name, long defaultValue)
name - the header namedefaultValue - the default valuelong value of the first value in insertion order or defaultValue if there is
no such value or it can't be converted into long.Float getFloatAndRemove(CharSequence name)
name - the header namefloat value of the first value in insertion order or null if there is
no such value or it can't be converted into float.float getFloatAndRemove(CharSequence name, float defaultValue)
name - the header namedefaultValue - the default valuefloat value of the first value in insertion order or defaultValue if there
is no such value or it can't be converted into float.Double getDoubleAndRemove(CharSequence name)
name - the header namedouble value of the first value in insertion order or null if there is
no such value or it can't be converted into double.double getDoubleAndRemove(CharSequence name, double defaultValue)
name - the header namedefaultValue - the default valuedouble value of the first value in insertion order or defaultValue if there
is no such value or it can't be converted into double.Long getTimeMillisAndRemove(CharSequence name)
name - the header namenull if there is no such
value or it can't be converted into milliseconds.long getTimeMillisAndRemove(CharSequence name, long defaultValue)
name - the header namedefaultValue - the default valuedefaultValue if there is
no such value or it can't be converted into milliseconds.HttpHeadersBuilder add(CharSequence name, String value)
name and value.name - the header namevalue - the header valuethisHttpHeadersBuilder add(CharSequence name, Iterable<String> values)
name and values. This method is semantically
equivalent to
for (String value : values) {
builder.add(name, value);
}
name - the header namevalues - the header valuesthisHttpHeadersBuilder add(CharSequence name, String... values)
name and values. This method is semantically
equivalent to
for (String value : values) {
builder.add(name, value);
}
name - the header namevalues - the header valuesthisHttpHeadersBuilder add(Iterable<? extends Map.Entry<? extends CharSequence,String>> entries)
entries.thisIllegalArgumentException - if entries == this.HttpHeadersBuilder addObject(CharSequence name, Object value)
String, as explained
in Specifying a non-String header value.name - the header namevalue - the header valuethisHttpHeadersBuilder addObject(CharSequence name, Iterable<?> values)
Strings, as explained in Specifying a non-String
header value. This method is equivalent to:
for (Object v : values) {
builder.addObject(name, v);
}
name - the header namevalues - the header valuesthisHttpHeadersBuilder addObject(CharSequence name, Object... values)
Strings, as explained in Specifying a non-String
header value. This method is equivalent to:
for (Object v : values) {
builder.addObject(name, v);
}
name - the header namevalues - the header valuesthisHttpHeadersBuilder addObject(Iterable<? extends Map.Entry<? extends CharSequence,?>> entries)
entries. The specified header values are
converted into Strings, as explained in Specifying
a non-String header value.thisIllegalArgumentException - if entries == this.HttpHeadersBuilder addInt(CharSequence name, int value)
name - the header namevalue - the header valuethisHttpHeadersBuilder addLong(CharSequence name, long value)
name - the header namevalue - the header valuethisHttpHeadersBuilder addFloat(CharSequence name, float value)
name - the header namevalue - the header valuethisHttpHeadersBuilder addDouble(CharSequence name, double value)
name - the header namevalue - the header valuethisHttpHeadersBuilder addTimeMillis(CharSequence name, long value)
name - the header namevalue - the header valuethisHttpHeadersBuilder set(CharSequence name, String value)
name - the header namevalue - the header valuethisHttpHeadersBuilder set(CharSequence name, Iterable<String> values)
builder.remove(name);
for (String v : values) {
builder.add(name, v);
}
name - the header namevalues - the header valuesthisHttpHeadersBuilder set(CharSequence name, String... values)
builder.remove(name);
for (String v : values) {
builder.add(name, v);
}
name - the header namevalues - the header valuesthisHttpHeadersBuilder set(Iterable<? extends Map.Entry<? extends CharSequence,String>> entries)
set(CharSequence, String) for each header in
the specified entries.entries - the headers used to set the header valuesthisHttpHeadersBuilder setIfAbsent(Iterable<? extends Map.Entry<? extends CharSequence,String>> entries)
entries.
This method is a shortcut for:
headers.names().forEach(name -> {
if (!builder.contains(name)) {
builder.set(name, headers.getAll(name));
}
});
thisHttpHeadersBuilder setObject(CharSequence name, Object value)
String, as explained in Specifying
a non-String header value.name - the header namevalue - the value of the headerthisHttpHeadersBuilder setObject(CharSequence name, Iterable<?> values)
Strings, as explained in
Specifying a non-String header value.
This method is equivalent to:
builder.remove(name);
for (Object v : values) {
builder.addObject(name, v);
}
name - the header namevalues - the values of the headerthisHttpHeadersBuilder setObject(CharSequence name, Object... values)
Strings, as explained in
Specifying a non-String header value.
This method is equivalent to:
builder.remove(name);
for (Object v : values) {
builder.addObject(name, v);
}
name - the header namevalues - the values of the headerthisHttpHeadersBuilder setObject(Iterable<? extends Map.Entry<? extends CharSequence,?>> entries)
setObject(CharSequence, Object) for each entry in
the specified entries. The specified header values are converted into Strings,
as explained in Specifying a non-String header value.entries - the headers used to set the values in this instancethisHttpHeadersBuilder setInt(CharSequence name, int value)
name to value. This will remove all previous values
associated with name.name - the header namevalue - the header valuethisHttpHeadersBuilder setLong(CharSequence name, long value)
name to value. This will remove all previous values
associated with name.name - the header namevalue - the header valuethisHttpHeadersBuilder setFloat(CharSequence name, float value)
name to value. This will remove all previous values
associated with name.name - the header namevalue - the header valuethisHttpHeadersBuilder setDouble(CharSequence name, double value)
name to value. This will remove all previous values
associated with name.name - the header namevalue - the header valuethisHttpHeadersBuilder setTimeMillis(CharSequence name, long value)
name to value. This will remove all previous values
associated with name.name - the header namevalue - the header valuethisboolean remove(CharSequence name)
name.name - the header nametrue if at least one entry has been removed.HttpHeadersBuilder removeAndThen(CharSequence name)
name. Unlike remove(CharSequence)
this method returns itself so that the caller can chain the invocations.name - the header namethisHttpHeadersBuilder clear()
size() becomes 0.thisboolean isEndOfStream()
MediaType contentType()
"content-type" header.MediaType if present and valid, or null otherwise.String get(CharSequence name)
name. If there are more than one value for
the specified name, the first value in insertion order is returned.name - the name of the header to retrievenull if there's no such headerString get(CharSequence name, String defaultValue)
name. If there are more than one value for
the specified name, the first value in insertion order is returned.name - the name of the header to retrievedefaultValue - the default valuedefaultValue if there is no such headerList<String> getAll(CharSequence name)
List can't be modified.Integer getInt(CharSequence name)
int value of a header with the specified name. If there are more than one
value for the specified name, the first value in insertion order is returned.name - the name of the header to retrieveint value of the first value in insertion order or null if there is no such
header or it can't be converted to int.int getInt(CharSequence name, int defaultValue)
int value of a header with the specified name. If there are more than one
value for the specified name, the first value in insertion order is returned.name - the name of the header to retrievedefaultValue - the default valueint value of the first value in insertion order or defaultValue if there is
no such header or it can't be converted to int.Long getLong(CharSequence name)
long value of a header with the specified name. If there are more than one
value for the specified name, the first value in insertion order is returned.name - the name of the header to retrievelong value of the first value in insertion order or null if there is no such
header or it can't be converted to long.long getLong(CharSequence name, long defaultValue)
long value of a header with the specified name. If there are more than one
value for the specified name, the first value in insertion order is returned.name - the name of the header to retrievedefaultValue - the default valuelong value of the first value in insertion order or defaultValue if there is
no such header or it can't be converted to long.Float getFloat(CharSequence name)
float value of a header with the specified name. If there are more than one
value for the specified name, the first value in insertion order is returned.name - the name of the header to retrievefloat value of the first value in insertion order or null if there is no
such header or it can't be converted to float.float getFloat(CharSequence name, float defaultValue)
float value of a header with the specified name. If there are more than one
value for the specified name, the first value in insertion order is returned.name - the name of the header to retrievedefaultValue - the default valuefloat value of the first value in insertion order or defaultValue if there
is no such header or it can't be converted to float.Double getDouble(CharSequence name)
double value of a header with the specified name. If there are more than one
value for the specified name, the first value in insertion order is returned.name - the name of the header to retrievedouble value of the first value in insertion order or null if there is no
such header or it can't be converted to double.double getDouble(CharSequence name, double defaultValue)
double value of a header with the specified name. If there are more than one
value for the specified name, the first value in insertion order is returned.name - the name of the header to retrievedefaultValue - the default valuedouble value of the first value in insertion order or defaultValue if there
is no such header or it can't be converted to double.Long getTimeMillis(CharSequence name)
name in milliseconds. If there are more than
one value for the specified name, the first value in insertion order is returned.name - the name of the header to retrievenull if there is no such
header or it can't be converted to milliseconds.long getTimeMillis(CharSequence name, long defaultValue)
name in milliseconds. If there are more than
one value for the specified name, the first value in insertion order is returned.name - the name of the header to retrievedefaultValue - the default valuedefaultValue if there is
no such header or it can't be converted to milliseconds.boolean contains(CharSequence name)
true if a header with the name exists, false otherwise.name - the header nameboolean contains(CharSequence name, String value)
true if a header with the name and value exists.name - the header namevalue - the header value of the header to findboolean containsObject(CharSequence name, Object value)
true if a header with the name and value exists.name - the header namevalue - the header valuetrue if the header exists. false otherwiseboolean containsInt(CharSequence name, int value)
true if a header with the name and value exists.name - the header namevalue - the header valuetrue if the header exists. false otherwiseboolean containsLong(CharSequence name, long value)
true if a header with the name and value exists.name - the header namevalue - the header valuetrue if the header exists. false otherwiseboolean containsFloat(CharSequence name, float value)
true if a header with the name and value exists.name - the header namevalue - the header valuetrue if the header exists. false otherwiseboolean containsDouble(CharSequence name, double value)
true if a header with the name and value exists.name - the header namevalue - the header valuetrue if the header exists. false otherwiseboolean containsTimeMillis(CharSequence name, long value)
true if a header with the name and value exists.name - the header namevalue - the header valuetrue if the header exists. false otherwiseint size()
boolean isEmpty()
true if this headers does not contain any entries.Set<io.netty.util.AsciiString> names()
Iterator<Map.Entry<io.netty.util.AsciiString,String>> iterator()
Iterator that yields all header entries. The iteration order is as follows:
Iterator<String> valueIterator(CharSequence name)
Iterator that yields all values of the headers with the specified name.void forEach(BiConsumer<io.netty.util.AsciiString,String> action)
action for all header entries.void forEachValue(CharSequence name, Consumer<String> action)
action for all values of the headers with the specified name.default Stream<Map.Entry<io.netty.util.AsciiString,String>> stream()
Stream that yields all header entries.default Stream<String> valueStream(CharSequence name)
Stream that yields all values of the headers with the specified name.Copyright © 2020 LeanCloud. All rights reserved.