Package com.linecorp.armeria.common
Interface RequestHeadersBuilder
-
- All Superinterfaces:
HttpHeadersBuilder
,Iterable<Map.Entry<AsciiString,String>>
public interface RequestHeadersBuilder extends HttpHeadersBuilder
Builds aRequestHeaders
.
-
-
Method Summary
Modifier and Type Method Description RequestHeadersBuilder
add(CharSequence name, Iterable<String> values)
Adds new headers with the specifiedname
andvalues
.RequestHeadersBuilder
add(CharSequence name, String value)
Adds a new header with the specifiedname
andvalue
.RequestHeadersBuilder
add(CharSequence name, String... values)
Adds new headers with the specifiedname
andvalues
.RequestHeadersBuilder
add(Iterable<? extends Map.Entry<? extends CharSequence,String>> headers)
Adds all header names and values of the specifiedheaders
.RequestHeadersBuilder
addDouble(CharSequence name, double value)
Adds a new header.RequestHeadersBuilder
addFloat(CharSequence name, float value)
Adds a new header.RequestHeadersBuilder
addInt(CharSequence name, int value)
Adds a new header.RequestHeadersBuilder
addLong(CharSequence name, long value)
Adds a new header.RequestHeadersBuilder
addObject(CharSequence name, Iterable<?> values)
Adds a new header with the specified name and values.RequestHeadersBuilder
addObject(CharSequence name, Object value)
Adds a new header.RequestHeadersBuilder
addObject(CharSequence name, Object... values)
Adds a new header with the specified name and values.RequestHeadersBuilder
addObject(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Adds all header names and values of the specifiedheaders
.RequestHeadersBuilder
addTimeMillis(CharSequence name, long value)
Adds a new header.String
authority()
Returns the value of the":authority"
header ornull
if there is no such header.default RequestHeadersBuilder
authority(Endpoint endpoint)
Sets the":authority"
header from the specifiedEndpoint
.RequestHeadersBuilder
authority(String authority)
Sets the":authority"
header.RequestHeaders
build()
Returns a newly createdRequestHeaders
with the entries in this builder.RequestHeadersBuilder
clear()
Removes all headers.boolean
contains(CharSequence name)
Returnstrue
if a header with thename
exists,false
otherwise.boolean
contains(CharSequence name, String value)
Returnstrue
if a header with thename
andvalue
exists.boolean
containsDouble(CharSequence name, double value)
Returnstrue
if a header with thename
andvalue
exists.boolean
containsFloat(CharSequence name, float value)
Returnstrue
if a header with thename
andvalue
exists.boolean
containsInt(CharSequence name, int value)
Returnstrue
if a header with thename
andvalue
exists.boolean
containsLong(CharSequence name, long value)
Returnstrue
if a header with thename
andvalue
exists.boolean
containsObject(CharSequence name, Object value)
Returnstrue
if a header with thename
andvalue
exists.boolean
containsTimeMillis(CharSequence name, long value)
Returnstrue
if a header with thename
andvalue
exists.MediaType
contentType()
Returns the parsed"content-type"
header.RequestHeadersBuilder
contentType(MediaType contentType)
Sets the"content-type"
header.RequestHeadersBuilder
endOfStream(boolean endOfStream)
Sets whether the headers will be the last frame in an HTTP/2 stream.void
forEach(BiConsumer<AsciiString,String> action)
Invokes the specifiedaction
for all header entries.void
forEachValue(CharSequence name, Consumer<String> action)
Invokes the specifiedaction
for all values of the headers with the specifiedname
.String
get(CharSequence name)
Returns the value of a header with the specifiedname
.String
get(CharSequence name, String defaultValue)
Returns the value of a header with the specifiedname
.List<String>
getAll(CharSequence name)
Returns all values for the header with the specified name.Double
getDouble(CharSequence name)
Returns thedouble
value of a header with the specifiedname
.double
getDouble(CharSequence name, double defaultValue)
Returns thedouble
value of a header with the specifiedname
.Float
getFloat(CharSequence name)
Returns thefloat
value of a header with the specifiedname
.float
getFloat(CharSequence name, float defaultValue)
Returns thefloat
value of a header with the specifiedname
.Integer
getInt(CharSequence name)
Returns theint
value of a header with the specifiedname
.int
getInt(CharSequence name, int defaultValue)
Returns theint
value of a header with the specifiedname
.Long
getLong(CharSequence name)
Returns thelong
value of a header with the specifiedname
.long
getLong(CharSequence name, long defaultValue)
Returns thelong
value of a header with the specifiedname
.Long
getTimeMillis(CharSequence name)
Returns the value of a header with the specifiedname
in milliseconds.long
getTimeMillis(CharSequence name, long defaultValue)
Returns the value of a header with the specifiedname
in milliseconds.boolean
isEmpty()
Returnstrue
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<AsciiString,String>>
iterator()
Returns anIterator
that yields all header entries.HttpMethod
method()
Returns the value of the":method"
header as anHttpMethod
.RequestHeadersBuilder
method(HttpMethod method)
Sets the":method"
header.Set<AsciiString>
names()
Returns aSet
of all header names.String
path()
Returns the value of the":path"
header.RequestHeadersBuilder
path(String path)
Sets the":path"
header.RequestHeadersBuilder
removeAndThen(CharSequence name)
Removes all headers with the specifiedname
.String
scheme()
Returns the value of the":scheme"
header ornull
if there is no such header.default RequestHeadersBuilder
scheme(SessionProtocol sessionProtocol)
Sets the":scheme"
header from the specifiedSessionProtocol
.RequestHeadersBuilder
scheme(String scheme)
Sets the":scheme"
header.RequestHeadersBuilder
set(CharSequence name, Iterable<String> values)
Sets a new header with the specified name and values.RequestHeadersBuilder
set(CharSequence name, String value)
Sets a header with the specified name and value.RequestHeadersBuilder
set(CharSequence name, String... values)
Sets a header with the specified name and values.RequestHeadersBuilder
set(Iterable<? extends Map.Entry<? extends CharSequence,String>> headers)
Retains all current headers but callsHttpHeadersBuilder.set(CharSequence, String)
for each entry in the specifiedheaders
.RequestHeadersBuilder
setDouble(CharSequence name, double value)
Sets a header with the specifiedname
tovalue
.RequestHeadersBuilder
setFloat(CharSequence name, float value)
Sets a header with the specifiedname
tovalue
.RequestHeadersBuilder
setIfAbsent(Iterable<? extends Map.Entry<? extends CharSequence,String>> headers)
Copies the entries missing in this headers from the specified headers.RequestHeadersBuilder
setInt(CharSequence name, int value)
Sets a header with the specifiedname
tovalue
.RequestHeadersBuilder
setLong(CharSequence name, long value)
Sets a header with the specifiedname
tovalue
.RequestHeadersBuilder
setObject(CharSequence name, Iterable<?> values)
Sets a header with the specified name and values.RequestHeadersBuilder
setObject(CharSequence name, Object value)
Sets a new header.RequestHeadersBuilder
setObject(CharSequence name, Object... values)
Sets a header with the specified name and values.RequestHeadersBuilder
setObject(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Retains all current headers but callsHttpHeadersBuilder.setObject(CharSequence, Object)
for each entry in the specifiedheaders
.RequestHeadersBuilder
setTimeMillis(CharSequence name, long value)
Sets a header with the specifiedname
tovalue
.int
size()
Returns the number of headers.RequestHeadersBuilder
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<AsciiString,String>>
stream()
Returns aStream
that yields all header entries.URI
uri()
Returns the request URI generated from the":scheme"
,":authority"
and":path"
headers.Iterator<String>
valueIterator(CharSequence name)
Returns anIterator
that yields all values of the headers with the specifiedname
.default Stream<String>
valueStream(CharSequence name)
Returns aStream
that yields all values of the headers with the specifiedname
.-
Methods inherited from interface com.linecorp.armeria.common.HttpHeadersBuilder
getAllAndRemove, getAndRemove, getAndRemove, getDoubleAndRemove, getDoubleAndRemove, getFloatAndRemove, getFloatAndRemove, getIntAndRemove, getIntAndRemove, getLongAndRemove, getLongAndRemove, getTimeMillisAndRemove, getTimeMillisAndRemove, remove
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
build
RequestHeaders build()
Returns a newly createdRequestHeaders
with the entries in this builder.- Specified by:
build
in interfaceHttpHeadersBuilder
- Throws:
IllegalStateException
- if this builder does not have":method"
and":path"
headers set.
-
method
RequestHeadersBuilder method(HttpMethod method)
Sets the":method"
header.
-
path
RequestHeadersBuilder path(String path)
Sets the":path"
header.
-
scheme
RequestHeadersBuilder scheme(String scheme)
Sets the":scheme"
header.
-
scheme
default RequestHeadersBuilder scheme(SessionProtocol sessionProtocol)
Sets the":scheme"
header from the specifiedSessionProtocol
.
-
authority
RequestHeadersBuilder authority(String authority)
Sets the":authority"
header.
-
authority
default RequestHeadersBuilder authority(Endpoint endpoint)
Sets the":authority"
header from the specifiedEndpoint
.- Throws:
IllegalArgumentException
- if the specifiedEndpoint
refers to a group
-
sizeHint
RequestHeadersBuilder sizeHint(int sizeHint)
Description copied from interface:HttpHeadersBuilder
Specifies the hint about the number of headers which may improve the memory efficiency and performance of the underlying data structure.- Specified by:
sizeHint
in interfaceHttpHeadersBuilder
- Returns:
this
-
endOfStream
RequestHeadersBuilder endOfStream(boolean endOfStream)
Description copied from interface:HttpHeadersBuilder
Sets whether the headers will be the last frame in an HTTP/2 stream.- Specified by:
endOfStream
in interfaceHttpHeadersBuilder
-
contentType
RequestHeadersBuilder contentType(MediaType contentType)
Description copied from interface:HttpHeadersBuilder
Sets the"content-type"
header.- Specified by:
contentType
in interfaceHttpHeadersBuilder
-
add
RequestHeadersBuilder add(CharSequence name, String value)
Description copied from interface:HttpHeadersBuilder
Adds a new header with the specifiedname
andvalue
.- Specified by:
add
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
add
RequestHeadersBuilder add(CharSequence name, Iterable<String> values)
Description copied from interface:HttpHeadersBuilder
Adds new headers with the specifiedname
andvalues
. This method is semantically equivalent tofor (String value : values) { headers.add(name, value); }
- Specified by:
add
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalues
- the header values- Returns:
this
-
add
RequestHeadersBuilder add(CharSequence name, String... values)
Description copied from interface:HttpHeadersBuilder
Adds new headers with the specifiedname
andvalues
. This method is semantically equivalent tofor (String value : values) { headers.add(name, value); }
- Specified by:
add
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalues
- the header values- Returns:
this
-
add
RequestHeadersBuilder add(Iterable<? extends Map.Entry<? extends CharSequence,String>> headers)
Description copied from interface:HttpHeadersBuilder
Adds all header names and values of the specifiedheaders
.- Specified by:
add
in interfaceHttpHeadersBuilder
- Returns:
this
-
addObject
RequestHeadersBuilder addObject(CharSequence name, Object value)
Description copied from interface:HttpHeadersBuilder
Adds a new header. The specified header value is converted into aString
, as explained in Specifying a non-String header value.- Specified by:
addObject
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
addObject
RequestHeadersBuilder addObject(CharSequence name, Iterable<?> values)
Description copied from interface:HttpHeadersBuilder
Adds a new header with the specified name and values. The specified header values are converted intoString
s, as explained in Specifying a non-String header value. This method is equivalent to:for (Object v : values) { headers.addObject(name, v); }
- Specified by:
addObject
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalues
- the header values- Returns:
this
-
addObject
RequestHeadersBuilder addObject(CharSequence name, Object... values)
Description copied from interface:HttpHeadersBuilder
Adds a new header with the specified name and values. The specified header values are converted intoString
s, as explained in Specifying a non-String header value. This method is equivalent to:for (Object v : values) { headers.addObject(name, v); }
- Specified by:
addObject
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalues
- the header values- Returns:
this
-
addObject
RequestHeadersBuilder addObject(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Description copied from interface:HttpHeadersBuilder
Adds all header names and values of the specifiedheaders
. The specified header values are converted intoString
s, as explained in Specifying a non-String header value.- Specified by:
addObject
in interfaceHttpHeadersBuilder
- Returns:
this
-
addInt
RequestHeadersBuilder addInt(CharSequence name, int value)
Description copied from interface:HttpHeadersBuilder
Adds a new header.- Specified by:
addInt
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
addLong
RequestHeadersBuilder addLong(CharSequence name, long value)
Description copied from interface:HttpHeadersBuilder
Adds a new header.- Specified by:
addLong
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
addFloat
RequestHeadersBuilder addFloat(CharSequence name, float value)
Description copied from interface:HttpHeadersBuilder
Adds a new header.- Specified by:
addFloat
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
addDouble
RequestHeadersBuilder addDouble(CharSequence name, double value)
Description copied from interface:HttpHeadersBuilder
Adds a new header.- Specified by:
addDouble
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
addTimeMillis
RequestHeadersBuilder addTimeMillis(CharSequence name, long value)
Description copied from interface:HttpHeadersBuilder
Adds a new header.- Specified by:
addTimeMillis
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
set
RequestHeadersBuilder set(CharSequence name, String value)
Description copied from interface:HttpHeadersBuilder
Sets a header with the specified name and value. Any existing headers with the same name are overwritten.- Specified by:
set
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
set
RequestHeadersBuilder set(CharSequence name, Iterable<String> values)
Description copied from interface:HttpHeadersBuilder
Sets a new header with the specified name and values. This method is equivalent toheaders.remove(name); for (String v : values) { headers.add(name, v); }
- Specified by:
set
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalues
- the header values- Returns:
this
-
set
RequestHeadersBuilder set(CharSequence name, String... values)
Description copied from interface:HttpHeadersBuilder
Sets a header with the specified name and values. Any existing headers with the specified name are removed. This method is equivalent to:headers.remove(name); for (String v : values) { headers.add(name, v); }
- Specified by:
set
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalues
- the header values- Returns:
this
-
set
RequestHeadersBuilder set(Iterable<? extends Map.Entry<? extends CharSequence,String>> headers)
Description copied from interface:HttpHeadersBuilder
Retains all current headers but callsHttpHeadersBuilder.set(CharSequence, String)
for each entry in the specifiedheaders
.- Specified by:
set
in interfaceHttpHeadersBuilder
- Parameters:
headers
- the headers used to set the header values- Returns:
this
-
setIfAbsent
RequestHeadersBuilder setIfAbsent(Iterable<? extends Map.Entry<? extends CharSequence,String>> headers)
Description copied from interface:HttpHeadersBuilder
Copies the entries missing in this headers from the specified headers. This method is a shortcut of the following code:headers.names().forEach(name -> { if (!contains(name)) { set(name, headers.getAll(name)); } });
- Specified by:
setIfAbsent
in interfaceHttpHeadersBuilder
- Returns:
this
-
setObject
RequestHeadersBuilder setObject(CharSequence name, Object value)
Description copied from interface:HttpHeadersBuilder
Sets a new header. Any existing headers with the specified name are removed. The specified header value is converted into aString
, as explained in Specifying a non-String header value.- Specified by:
setObject
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the value of the header- Returns:
this
-
setObject
RequestHeadersBuilder setObject(CharSequence name, Iterable<?> values)
Description copied from interface:HttpHeadersBuilder
Sets a header with the specified name and values. Any existing headers with the specified name are removed. The specified header values are converted intoString
s, as explained in Specifying a non-String header value. This method is equivalent to:headers.remove(name); for (Object v : values) { headers.addObject(name, v); }
- Specified by:
setObject
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalues
- the values of the header- Returns:
this
-
setObject
RequestHeadersBuilder setObject(CharSequence name, Object... values)
Description copied from interface:HttpHeadersBuilder
Sets a header with the specified name and values. Any existing headers with the specified name are removed. The specified header values are converted intoString
s, as explained in Specifying a non-String header value. This method is equivalent to:headers.remove(name); for (Object v : values) { headers.addObject(name, v); }
- Specified by:
setObject
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalues
- the values of the header- Returns:
this
-
setObject
RequestHeadersBuilder setObject(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Description copied from interface:HttpHeadersBuilder
Retains all current headers but callsHttpHeadersBuilder.setObject(CharSequence, Object)
for each entry in the specifiedheaders
. The specified header values are converted intoString
s, as explained in Specifying a non-String header value.- Specified by:
setObject
in interfaceHttpHeadersBuilder
- Parameters:
headers
- the headers used to set the values in this instance- Returns:
this
-
setInt
RequestHeadersBuilder setInt(CharSequence name, int value)
Description copied from interface:HttpHeadersBuilder
Sets a header with the specifiedname
tovalue
. This will remove all previous values associated withname
.- Specified by:
setInt
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
setLong
RequestHeadersBuilder setLong(CharSequence name, long value)
Description copied from interface:HttpHeadersBuilder
Sets a header with the specifiedname
tovalue
. This will remove all previous values associated withname
.- Specified by:
setLong
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
setFloat
RequestHeadersBuilder setFloat(CharSequence name, float value)
Description copied from interface:HttpHeadersBuilder
Sets a header with the specifiedname
tovalue
. This will remove all previous values associated withname
.- Specified by:
setFloat
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
setDouble
RequestHeadersBuilder setDouble(CharSequence name, double value)
Description copied from interface:HttpHeadersBuilder
Sets a header with the specifiedname
tovalue
. This will remove all previous values associated withname
.- Specified by:
setDouble
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
setTimeMillis
RequestHeadersBuilder setTimeMillis(CharSequence name, long value)
Description copied from interface:HttpHeadersBuilder
Sets a header with the specifiedname
tovalue
. This will remove all previous values associated withname
.- Specified by:
setTimeMillis
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header namevalue
- the header value- Returns:
this
-
removeAndThen
RequestHeadersBuilder removeAndThen(CharSequence name)
Description copied from interface:HttpHeadersBuilder
Removes all headers with the specifiedname
. UnlikeHttpHeadersBuilder.remove(CharSequence)
this method returns itself so that the caller can chain the invocations.- Specified by:
removeAndThen
in interfaceHttpHeadersBuilder
- Parameters:
name
- the header name- Returns:
this
-
clear
RequestHeadersBuilder clear()
Description copied from interface:HttpHeadersBuilder
Removes all headers. After a call to this method,size()
becomes0
.- Specified by:
clear
in interfaceHttpHeadersBuilder
- Returns:
this
-
isEndOfStream
boolean isEndOfStream()
Tells whether the headers correspond to the last frame in an HTTP/2 stream.
-
contentType
@Nullable MediaType contentType()
Returns the parsed"content-type"
header.- Returns:
- the parsed
MediaType
if present and valid.null
otherwise.
-
get
@Nullable String get(CharSequence name)
Returns the value of a header with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrieve- Returns:
- the first header value if the header is found.
null
if there's no such header
-
get
String get(CharSequence name, String defaultValue)
Returns the value of a header with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the first header value or
defaultValue
if there is no such header
-
getAll
List<String> getAll(CharSequence name)
Returns all values for the header with the specified name. The returnedList
can't be modified.
-
getInt
@Nullable Integer getInt(CharSequence name)
Returns theint
value of a header with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrieve- Returns:
- the
int
value of the first value in insertion order ornull
if there is no such header or it can't be converted toint
.
-
getInt
int getInt(CharSequence name, int defaultValue)
Returns theint
value of a header with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
int
value of the first value in insertion order ordefaultValue
if there is no such header or it can't be converted toint
.
-
getLong
@Nullable Long getLong(CharSequence name)
Returns thelong
value of a header with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrieve- Returns:
- the
long
value of the first value in insertion order ornull
if there is no such header or it can't be converted tolong
.
-
getLong
long getLong(CharSequence name, long defaultValue)
Returns thelong
value of a header with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
long
value of the first value in insertion order ordefaultValue
if there is no such header or it can't be converted tolong
.
-
getFloat
@Nullable Float getFloat(CharSequence name)
Returns thefloat
value of a header with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrieve- Returns:
- the
float
value of the first value in insertion order ornull
if there is no such header or it can't be converted tofloat
.
-
getFloat
float getFloat(CharSequence name, float defaultValue)
Returns thefloat
value of a header with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
float
value of the first value in insertion order ordefaultValue
if there is no such header or it can't be converted tofloat
.
-
getDouble
@Nullable Double getDouble(CharSequence name)
Returns thedouble
value of a header with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrieve- Returns:
- the
double
value of the first value in insertion order ornull
if there is no such header or it can't be converted todouble
.
-
getDouble
double getDouble(CharSequence name, double defaultValue)
Returns thedouble
value of a header with the specifiedname
. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
double
value of the first value in insertion order ordefaultValue
if there is no such header or it can't be converted todouble
.
-
getTimeMillis
@Nullable Long getTimeMillis(CharSequence name)
Returns the value of a header with the specifiedname
in milliseconds. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrieve- Returns:
- the milliseconds value of the first value in insertion order or
null
if there is no such header or it can't be converted to milliseconds.
-
getTimeMillis
long getTimeMillis(CharSequence name, long defaultValue)
Returns the value of a header with the specifiedname
in milliseconds. If there are more than one value for the specifiedname
, the first value in insertion order is returned.- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the milliseconds value of the first value in insertion order or
defaultValue
if there is no such header or it can't be converted to milliseconds.
-
contains
boolean contains(CharSequence name)
Returnstrue
if a header with thename
exists,false
otherwise.- Parameters:
name
- the header name
-
contains
boolean contains(CharSequence name, String value)
Returnstrue
if a header with thename
andvalue
exists.- Parameters:
name
- the header namevalue
- the header value of the header to find
-
containsObject
boolean containsObject(CharSequence name, Object value)
Returnstrue
if a header with thename
andvalue
exists.- Parameters:
name
- the header namevalue
- the header value- Returns:
true
if the header exists.false
otherwise
-
containsInt
boolean containsInt(CharSequence name, int value)
Returnstrue
if a header with thename
andvalue
exists.- Parameters:
name
- the header namevalue
- the header value- Returns:
true
if the header exists.false
otherwise
-
containsLong
boolean containsLong(CharSequence name, long value)
Returnstrue
if a header with thename
andvalue
exists.- Parameters:
name
- the header namevalue
- the header value- Returns:
true
if the header exists.false
otherwise
-
containsFloat
boolean containsFloat(CharSequence name, float value)
Returnstrue
if a header with thename
andvalue
exists.- Parameters:
name
- the header namevalue
- the header value- Returns:
true
if the header exists.false
otherwise
-
containsDouble
boolean containsDouble(CharSequence name, double value)
Returnstrue
if a header with thename
andvalue
exists.- Parameters:
name
- the header namevalue
- the header value- Returns:
true
if the header exists.false
otherwise
-
containsTimeMillis
boolean containsTimeMillis(CharSequence name, long value)
Returnstrue
if a header with thename
andvalue
exists.- Parameters:
name
- the header namevalue
- the header value- Returns:
true
if the header exists.false
otherwise
-
size
int size()
Returns the number of headers.
-
isEmpty
boolean isEmpty()
Returnstrue
if this headers does not contain any entries.
-
names
Set<AsciiString> names()
-
iterator
Iterator<Map.Entry<AsciiString,String>> iterator()
Returns anIterator
that yields all header entries. The iteration order is as follows:- All pseudo headers (order not specified).
- All non-pseudo headers (in insertion order).
- Specified by:
iterator
in interfaceIterable<Map.Entry<AsciiString,String>>
-
valueIterator
Iterator<String> valueIterator(CharSequence name)
Returns anIterator
that yields all values of the headers with the specifiedname
.
-
forEach
void forEach(BiConsumer<AsciiString,String> action)
Invokes the specifiedaction
for all header entries.
-
forEachValue
void forEachValue(CharSequence name, Consumer<String> action)
Invokes the specifiedaction
for all values of the headers with the specifiedname
.
-
stream
default Stream<Map.Entry<AsciiString,String>> stream()
Returns aStream
that yields all header entries.
-
valueStream
default Stream<String> valueStream(CharSequence name)
Returns aStream
that yields all values of the headers with the specifiedname
.
-
uri
URI uri()
Returns the request URI generated from the":scheme"
,":authority"
and":path"
headers.- Throws:
IllegalStateException
- if any of the required headers do not exist or the resulting URI is not valid.
-
method
HttpMethod method()
Returns the value of the":method"
header as anHttpMethod
.HttpMethod.UNKNOWN
is returned if the value is not defined inHttpMethod
.- Throws:
IllegalStateException
- if there is no such header.
-
path
String path()
Returns the value of the":path"
header.- Throws:
IllegalStateException
- if there is no such header.
-
scheme
@Nullable String scheme()
Returns the value of the":scheme"
header ornull
if there is no such header.
-
authority
@Nullable String authority()
Returns the value of the":authority"
header ornull
if there is no such header.
-
-