Package com.linecorp.armeria.common
Interface HttpHeaders
-
- All Superinterfaces:
Headers<AsciiString,String,HttpHeaders>
,HttpObject
,Iterable<Map.Entry<AsciiString,String>>
- All Known Implementing Classes:
DefaultHttpHeaders
public interface HttpHeaders extends HttpObject, Headers<AsciiString,String,HttpHeaders>
HTTP/2 headers.
-
-
Field Summary
Fields Modifier and Type Field Description static HttpHeaders
EMPTY_HEADERS
An immutable empty HTTP/2 headers.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default HttpHeaders
asImmutable()
Returns the immutable view of this headers.String
authority()
Gets theHttpHeaderNames.AUTHORITY
header ornull
if there is no such header.HttpHeaders
authority(String authority)
Sets theHttpHeaderNames.AUTHORITY
header.MediaType
contentType()
Returns the value of the'content-type'
header.HttpHeaders
contentType(MediaType mediaType)
Sets theHttpHeaderNames.CONTENT_TYPE
header.static HttpHeaders
copyOf(HttpHeaders headers)
Returns a copy of the specifiedHttpHeaders
.default boolean
isImmutable()
Returns whether this is immutable or not.Iterator<Map.Entry<AsciiString,String>>
iterator()
Returns an iterator over all HTTP/2 headers.HttpMethod
method()
Gets theHttpHeaderNames.METHOD
header ornull
if there is no such header.HttpHeaders
method(HttpMethod method)
Sets theHttpHeaderNames.METHOD
header.static HttpHeaders
of()
Returns new empty HTTP headers.static HttpHeaders
of(int statusCode)
Returns new HTTP response headers.static HttpHeaders
of(HttpMethod method, String path)
Returns new HTTP request headers.static HttpHeaders
of(HttpStatus status)
Returns new HTTP response headers.static HttpHeaders
of(AsciiString name, String value)
Returns new HTTP headers with a single entry.static HttpHeaders
of(AsciiString name1, String value1, AsciiString name2, String value2)
Returns new HTTP headers with two entries.static HttpHeaders
of(AsciiString name1, String value1, AsciiString name2, String value2, AsciiString name3, String value3)
Returns new HTTP headers with three entries.static HttpHeaders
of(AsciiString name1, String value1, AsciiString name2, String value2, AsciiString name3, String value3, AsciiString name4, String value4)
Returns new HTTP headers with four entries.String
path()
Gets theHttpHeaderNames.PATH
header ornull
if there is no such header.HttpHeaders
path(String path)
Sets theHttpHeaderNames.PATH
header.String
scheme()
Gets theHttpHeaderNames.SCHEME
header ornull
if there is no such header.HttpHeaders
scheme(String scheme)
Sets theHttpHeaderNames.SCHEME
header.default HttpHeaders
setAllIfAbsent(Headers<? extends AsciiString,? extends String,?> headers)
Copies the entries missing in this headers from the specifiedHeaders
.HttpStatus
status()
Gets theHttpHeaderNames.STATUS
header ornull
if there is no such header.HttpHeaders
status(int statusCode)
Sets theHttpHeaderNames.STATUS
header.HttpHeaders
status(HttpStatus status)
Sets theHttpHeaderNames.STATUS
header.-
Methods inherited from interface io.netty.handler.codec.Headers
add, add, add, add, addBoolean, addByte, addChar, addDouble, addFloat, addInt, addLong, addObject, addObject, addObject, addShort, addTimeMillis, clear, contains, contains, containsBoolean, containsByte, containsChar, containsDouble, containsFloat, containsInt, containsLong, containsObject, containsShort, containsTimeMillis, get, get, getAll, getAllAndRemove, getAndRemove, getAndRemove, getBoolean, getBoolean, getBooleanAndRemove, getBooleanAndRemove, getByte, getByte, getByteAndRemove, getByteAndRemove, getChar, getChar, getCharAndRemove, getCharAndRemove, getDouble, getDouble, getDoubleAndRemove, getDoubleAndRemove, getFloat, getFloat, getFloatAndRemove, getFloatAndRemove, getInt, getInt, getIntAndRemove, getIntAndRemove, getLong, getLong, getLongAndRemove, getLongAndRemove, getShort, getShort, getShortAndRemove, getShortAndRemove, getTimeMillis, getTimeMillis, getTimeMillisAndRemove, getTimeMillisAndRemove, isEmpty, names, remove, set, set, set, set, setAll, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setObject, setObject, setObject, setShort, setTimeMillis, size
-
Methods inherited from interface com.linecorp.armeria.common.HttpObject
isEndOfStream
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
EMPTY_HEADERS
static final HttpHeaders EMPTY_HEADERS
An immutable empty HTTP/2 headers.
-
-
Method Detail
-
of
static HttpHeaders of()
Returns new empty HTTP headers.
-
of
static HttpHeaders of(HttpMethod method, String path)
Returns new HTTP request headers.
-
of
static HttpHeaders of(int statusCode)
Returns new HTTP response headers.
-
of
static HttpHeaders of(HttpStatus status)
Returns new HTTP response headers.
-
of
static HttpHeaders of(AsciiString name, String value)
Returns new HTTP headers with a single entry.
-
of
static HttpHeaders of(AsciiString name1, String value1, AsciiString name2, String value2)
Returns new HTTP headers with two entries.
-
of
static HttpHeaders of(AsciiString name1, String value1, AsciiString name2, String value2, AsciiString name3, String value3)
Returns new HTTP headers with three entries.
-
of
static HttpHeaders of(AsciiString name1, String value1, AsciiString name2, String value2, AsciiString name3, String value3, AsciiString name4, String value4)
Returns new HTTP headers with four entries.
-
copyOf
static HttpHeaders copyOf(HttpHeaders headers)
Returns a copy of the specifiedHttpHeaders
.
-
iterator
Iterator<Map.Entry<AsciiString,String>> iterator()
Returns an iterator over all HTTP/2 headers. The iteration order is as follows: 1. All pseudo headers (order not specified). 2. All non-pseudo headers (in insertion order).- Specified by:
iterator
in interfaceHeaders<AsciiString,String,HttpHeaders>
- Specified by:
iterator
in interfaceIterable<Map.Entry<AsciiString,String>>
-
method
@Nullable HttpMethod method()
Gets theHttpHeaderNames.METHOD
header ornull
if there is no such header.HttpMethod.UNKNOWN
is returned if the value of theHttpHeaderNames.METHOD
header is not defined inHttpMethod
.
-
method
HttpHeaders method(HttpMethod method)
Sets theHttpHeaderNames.METHOD
header.
-
scheme
@Nullable String scheme()
Gets theHttpHeaderNames.SCHEME
header ornull
if there is no such header.
-
scheme
HttpHeaders scheme(String scheme)
Sets theHttpHeaderNames.SCHEME
header.
-
authority
@Nullable String authority()
Gets theHttpHeaderNames.AUTHORITY
header ornull
if there is no such header.
-
authority
HttpHeaders authority(String authority)
Sets theHttpHeaderNames.AUTHORITY
header.
-
path
@Nullable String path()
Gets theHttpHeaderNames.PATH
header ornull
if there is no such header.
-
path
HttpHeaders path(String path)
Sets theHttpHeaderNames.PATH
header.
-
status
@Nullable HttpStatus status()
Gets theHttpHeaderNames.STATUS
header ornull
if there is no such header.
-
status
HttpHeaders status(int statusCode)
Sets theHttpHeaderNames.STATUS
header.
-
status
HttpHeaders status(HttpStatus status)
Sets theHttpHeaderNames.STATUS
header.
-
contentType
@Nullable MediaType contentType()
Returns the value of the'content-type'
header.- Returns:
- the valid header value if present.
null
otherwise.
-
contentType
HttpHeaders contentType(MediaType mediaType)
Sets theHttpHeaderNames.CONTENT_TYPE
header.
-
setAllIfAbsent
default HttpHeaders setAllIfAbsent(Headers<? extends AsciiString,? extends String,?> headers)
Copies the entries missing in this headers from the specifiedHeaders
. This method is a shortcut of the following code:headers.forEach(entry -> { final AsciiString name = entry.getKey(); if (!this.contains(name)) { this.set(name, entry.getValue()); } });
-
asImmutable
default HttpHeaders asImmutable()
Returns the immutable view of this headers.
-
isImmutable
default boolean isImmutable()
Returns whether this is immutable or not.
-
-