Package io.micronaut.http.netty
Class NettyHttpHeaders
java.lang.Object
io.micronaut.http.netty.NettyHttpHeaders
- All Implemented Interfaces:
ConversionServiceAware
,ConversionServiceProvider
,ConvertibleMultiValues<String>
,ConvertibleValues<List<String>>
,Headers
,MutableHeaders
,ValueResolver<CharSequence>
,HttpHeaders
,MutableHttpHeaders
,Iterable<Map.Entry<String,
List<String>>>
Delegates to Netty's
HttpHeaders
.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields inherited from interface io.micronaut.core.convert.value.ConvertibleValues
EMPTY
Fields inherited from interface io.micronaut.http.HttpHeaders
ACCEPT, ACCEPT_CH, ACCEPT_CH_LIFETIME, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ACCEPT_PATCH, ACCEPT_RANGES, ACCESS_CONTROL_ALLOW_CREDENTIALS, ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_ALLOW_PRIVATE_NETWORK, ACCESS_CONTROL_EXPOSE_HEADERS, ACCESS_CONTROL_MAX_AGE, ACCESS_CONTROL_REQUEST_HEADERS, ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_PRIVATE_NETWORK, AGE, ALLOW, AUTHORIZATION, AUTHORIZATION_INFO, CACHE_CONTROL, CONNECTION, CONTENT_BASE, CONTENT_DISPOSITION, CONTENT_DPR, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_MD5, CONTENT_RANGE, CONTENT_TRANSFER_ENCODING, CONTENT_TYPE, COOKIE, CROSS_ORIGIN_RESOURCE_POLICY, DATE, DEVICE_MEMORY, DOWNLINK, DPR, ECT, ETAG, EXPECT, EXPIRES, FEATURE_POLICY, FORWARDED, FROM, HOST, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_RANGE, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LINK, LOCATION, MAX_FORWARDS, ORIGIN, PRAGMA, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, RANGE, REFERER, REFERRER_POLICY, RETRY_AFTER, RTT, SAVE_DATA, SEC_WEBSOCKET_ACCEPT, SEC_WEBSOCKET_KEY, SEC_WEBSOCKET_KEY1, SEC_WEBSOCKET_KEY2, SEC_WEBSOCKET_LOCATION, SEC_WEBSOCKET_ORIGIN, SEC_WEBSOCKET_PROTOCOL, SEC_WEBSOCKET_VERSION, SERVER, SET_COOKIE, SET_COOKIE2, SOURCE_MAP, STANDARD_HEADERS, TE, TRAILER, TRANSFER_ENCODING, UPGRADE, USER_AGENT, VARY, VIA, VIEWPORT_WIDTH, WARNING, WEBSOCKET_LOCATION, WEBSOCKET_ORIGIN, WEBSOCKET_PROTOCOL, WIDTH, WWW_AUTHENTICATE, X_AUTH_TOKEN
Fields inherited from interface io.micronaut.http.MutableHttpHeaders
GMT
-
Constructor Summary
ConstructorDescriptionDefault constructor.NettyHttpHeaders
(io.netty.handler.codec.http.HttpHeaders nettyHeaders, ConversionService conversionService) -
Method Summary
Modifier and TypeMethodDescriptionaccept()
A list of acceptedMediaType
instances.add
(CharSequence header, CharSequence value) Add a header for the given name and value.allowGeneric
(Collection<? extends CharSequence> methods) Set the allowed HTTP methods.Used to configure BASIC authentication.final boolean
contains
(CharSequence name) Whether the given key is contained within these values.final boolean
Whether the given key is contained within these values.The request or response content type.The request or response content type.contentType
(MediaType mediaType) Sets theHttpHeaders.CONTENT_TYPE
header to the given media type.date
(long timeInMillis) Adds the DATE header for the givenLong
.date
(LocalDateTime date) Adds the date header for the givenLocalDateTime
.expires
(long timeInMillis) Adds the EXPIRES header for the givenLong
.expires
(LocalDateTime date) Adds the EXPIRES header for the givenLocalDateTime
.TheAccept-Charset
header, or empty if unset.TheAccept-Language
header, or empty if unset.findFirst
(CharSequence name) Get the first value of the given header.get
(CharSequence name) Get a value without applying any conversion.<T> Optional<T>
get
(CharSequence name, ArgumentConversionContext<T> conversionContext) Resolve the given property for the given name.getAll
(CharSequence name) Get all the values for the given name without applying conversion.Provides the conversion service.io.netty.handler.codec.http.HttpHeaders
Note: Caller must take care to validate headers inserted into this object!ifModifiedSince
(long timeInMillis) Adds the IF_MODIFIED_SINCE header for the givenLong
.ifModifiedSince
(LocalDateTime date) Adds the IF_MODIFIED_SINCE header for the givenZonedDateTime
.lastModified
(long timeInMillis) Adds the LAST_MODIFIED header for the givenLong
.lastModified
(LocalDateTime date) Adds the LAST_MODIFIED header for the givenLocalDateTime
.Sets the location header to the given URI.names()
remove
(CharSequence header) Removes a header.set
(CharSequence header, CharSequence value) Sets an HTTP header overriding any existing value.void
setConversionService
(ConversionService conversionService) Sets the conversion service.void
setUnsafe
(CharSequence header, CharSequence value) Likeset(CharSequence, CharSequence)
but without header validation.static void
validateHeader
(CharSequence name, CharSequence value) values()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.convert.value.ConvertibleMultiValues
forEach, forEachValue, getFirst, getFirst, getFirst, getFirst, getFirst, isEmpty, iterator
Methods inherited from interface io.micronaut.core.convert.value.ConvertibleValues
asMap, asMap, asProperties, getValue, getValueType, subMap, subMap, subMap
Methods inherited from interface io.micronaut.http.HttpHeaders
acceptCharset, acceptLanguage, findDate, findInt, getAuthorization, getContentType, getDate, getInt, isKeepAlive
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface io.micronaut.core.type.MutableHeaders
setIfMissing
Methods inherited from interface io.micronaut.core.value.ValueResolver
get, get, get
-
Constructor Details
-
NettyHttpHeaders
public NettyHttpHeaders(io.netty.handler.codec.http.HttpHeaders nettyHeaders, ConversionService conversionService) - Parameters:
nettyHeaders
- The Netty Http headersconversionService
- The conversion service
-
NettyHttpHeaders
public NettyHttpHeaders()Default constructor.
-
-
Method Details
-
getNettyHeaders
public io.netty.handler.codec.http.HttpHeaders getNettyHeaders()Note: Caller must take care to validate headers inserted into this object!- Returns:
- The underlying Netty headers.
-
contains
Description copied from interface:ConvertibleValues
Whether the given key is contained within these values.- Specified by:
contains
in interfaceConvertibleValues<List<String>>
- Parameters:
name
- The key name- Returns:
- True if it is
-
contains
Description copied from interface:HttpHeaders
Whether the given key is contained within these values.- Specified by:
contains
in interfaceHttpHeaders
- Parameters:
name
- The key name- Returns:
- True if it is
-
get
Description copied from interface:ValueResolver
Resolve the given property for the given name.- Specified by:
get
in interfaceValueResolver<CharSequence>
- Type Parameters:
T
- The concrete type- Parameters:
name
- The nameconversionContext
- The conversion context- Returns:
- An optional containing the property value if it exists and is able to be converted
-
getAll
Description copied from interface:ConvertibleMultiValues
Get all the values for the given name without applying conversion.- Specified by:
getAll
in interfaceConvertibleMultiValues<String>
- Parameters:
name
- The header name- Returns:
- All the values
-
names
- Specified by:
names
in interfaceConvertibleValues<List<String>>
- Returns:
- The names of the values
-
values
- Specified by:
values
in interfaceConvertibleValues<List<String>>
- Returns:
- The values
-
get
Description copied from interface:ConvertibleMultiValues
Get a value without applying any conversion.- Specified by:
get
in interfaceConvertibleMultiValues<String>
- Parameters:
name
- The name of the value- Returns:
- The raw value or null
- See Also:
-
findFirst
Description copied from interface:HttpHeaders
Get the first value of the given header.- Specified by:
findFirst
in interfaceHttpHeaders
- Parameters:
name
- The header name- Returns:
- The first value or null if it is present
-
add
Description copied from interface:MutableHttpHeaders
Add a header for the given name and value.- Specified by:
add
in interfaceMutableHeaders
- Specified by:
add
in interfaceMutableHttpHeaders
- Parameters:
header
- The header namevalue
- The value- Returns:
- This headers object
-
set
Description copied from interface:MutableHeaders
Sets an HTTP header overriding any existing value.- Specified by:
set
in interfaceMutableHeaders
- Specified by:
set
in interfaceMutableHttpHeaders
- Parameters:
header
- The headervalue
- The value- Returns:
- This headers
-
setUnsafe
Likeset(CharSequence, CharSequence)
but without header validation.- Parameters:
header
- The header namevalue
- The header value
-
validateHeader
-
remove
Description copied from interface:MutableHeaders
Removes a header.- Specified by:
remove
in interfaceMutableHeaders
- Specified by:
remove
in interfaceMutableHttpHeaders
- Parameters:
header
- The header to remove- Returns:
- These headers
-
date
Description copied from interface:MutableHttpHeaders
Adds the date header for the givenLocalDateTime
.- Specified by:
date
in interfaceMutableHttpHeaders
- Parameters:
date
- The local date time (assumed to represent system's default time-zoneZoneId.systemDefault()
, will be converted to GMT) as perDateTimeFormatter.RFC_1123_DATE_TIME
- Returns:
- The
MutableHttpHeaders
- See Also:
-
expires
Description copied from interface:MutableHttpHeaders
Adds the EXPIRES header for the givenLocalDateTime
.- Specified by:
expires
in interfaceMutableHttpHeaders
- Parameters:
date
- The local date time (assumed to represent system's default time-zoneZoneId.systemDefault()
, will be converted to GMT) as perDateTimeFormatter.RFC_1123_DATE_TIME
- Returns:
- The
MutableHttpHeaders
- See Also:
-
lastModified
Description copied from interface:MutableHttpHeaders
Adds the LAST_MODIFIED header for the givenLocalDateTime
.- Specified by:
lastModified
in interfaceMutableHttpHeaders
- Parameters:
date
- The local date time (assumed to represent system's default time-zoneZoneId.systemDefault()
, will be converted to GMT) as perDateTimeFormatter.RFC_1123_DATE_TIME
- Returns:
- The
MutableHttpHeaders
- See Also:
-
ifModifiedSince
Description copied from interface:MutableHttpHeaders
Adds the IF_MODIFIED_SINCE header for the givenZonedDateTime
.- Specified by:
ifModifiedSince
in interfaceMutableHttpHeaders
- Parameters:
date
- The local date time (assumed to represent system's default time-zoneZoneId.systemDefault()
, will be converted to GMT) as perDateTimeFormatter.RFC_1123_DATE_TIME
- Returns:
- The
MutableHttpHeaders
- See Also:
-
date
Description copied from interface:MutableHttpHeaders
Adds the DATE header for the givenLong
.- Specified by:
date
in interfaceMutableHttpHeaders
- Parameters:
timeInMillis
- The time in milliseconds since Epoch.- Returns:
- The
MutableHttpHeaders
-
expires
Description copied from interface:MutableHttpHeaders
Adds the EXPIRES header for the givenLong
.- Specified by:
expires
in interfaceMutableHttpHeaders
- Parameters:
timeInMillis
- The time in milliseconds since Epoch.- Returns:
- The
MutableHttpHeaders
-
lastModified
Description copied from interface:MutableHttpHeaders
Adds the LAST_MODIFIED header for the givenLong
.- Specified by:
lastModified
in interfaceMutableHttpHeaders
- Parameters:
timeInMillis
- The time in milliseconds since Epoch.- Returns:
- The
MutableHttpHeaders
-
ifModifiedSince
Description copied from interface:MutableHttpHeaders
Adds the IF_MODIFIED_SINCE header for the givenLong
.- Specified by:
ifModifiedSince
in interfaceMutableHttpHeaders
- Parameters:
timeInMillis
- The time in milliseconds since Epoch.- Returns:
- The
MutableHttpHeaders
-
auth
Description copied from interface:MutableHttpHeaders
Used to configure BASIC authentication.- Specified by:
auth
in interfaceMutableHttpHeaders
- Parameters:
userInfo
- The user info which is in the form "username:password"- Returns:
- This HTTP headers
-
allowGeneric
Description copied from interface:MutableHttpHeaders
Set the allowed HTTP methods.- Specified by:
allowGeneric
in interfaceMutableHttpHeaders
- Parameters:
methods
- The methods to specify in the Allowed HTTP header- Returns:
- This HTTP headers
-
location
Description copied from interface:MutableHttpHeaders
Sets the location header to the given URI.- Specified by:
location
in interfaceMutableHttpHeaders
- Parameters:
uri
- The URI- Returns:
- This HTTP headers
-
contentType
Description copied from interface:MutableHttpHeaders
Sets theHttpHeaders.CONTENT_TYPE
header to the given media type.- Specified by:
contentType
in interfaceMutableHttpHeaders
- Parameters:
mediaType
- The media type- Returns:
- This HTTP headers
-
getConversionService
Description copied from interface:ConversionServiceProvider
Provides the conversion service.- Specified by:
getConversionService
in interfaceConversionServiceProvider
- Specified by:
getConversionService
in interfaceConvertibleValues<List<String>>
- Returns:
- the conversion service
-
setConversionService
Description copied from interface:ConversionServiceAware
Sets the conversion service.- Specified by:
setConversionService
in interfaceConversionServiceAware
- Parameters:
conversionService
- The conversion service
-
contentType
Description copied from interface:HttpHeaders
The request or response content type.- Specified by:
contentType
in interfaceHttpHeaders
- Returns:
- The content type
-
contentLength
Description copied from interface:HttpHeaders
The request or response content type.- Specified by:
contentLength
in interfaceHttpHeaders
- Returns:
- The content type
-
accept
Description copied from interface:HttpHeaders
A list of acceptedMediaType
instances.- Specified by:
accept
in interfaceHttpHeaders
- Returns:
- A list of zero or many
MediaType
instances
-
findAcceptCharset
Description copied from interface:HttpHeaders
TheAccept-Charset
header, or empty if unset.- Specified by:
findAcceptCharset
in interfaceHttpHeaders
- Returns:
- The
Accept-Charset
header
-
findAcceptLanguage
Description copied from interface:HttpHeaders
TheAccept-Language
header, or empty if unset.- Specified by:
findAcceptLanguage
in interfaceHttpHeaders
- Returns:
- The
Accept-Language
header
-
getOrigin
- Specified by:
getOrigin
in interfaceHttpHeaders
- Returns:
- The
HttpHeaders.ORIGIN
header
-