Class NettyHttpServerConfiguration
- java.lang.Object
-
- io.micronaut.http.server.HttpServerConfiguration
-
- io.micronaut.http.server.netty.configuration.NettyHttpServerConfiguration
-
- All Implemented Interfaces:
io.micronaut.http.context.ServerContextPathProvider
@ConfigurationProperties("netty") @Replaces(io.micronaut.http.server.HttpServerConfiguration.class) public class NettyHttpServerConfiguration extends io.micronaut.http.server.HttpServerConfigurationAllows configuring Netty withinNettyHttpServer.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNettyHttpServerConfiguration.AccessLoggerAccess logger configuration.static classNettyHttpServerConfiguration.EventLoopConfigAbstract class for configuring the Netty event loop.static classNettyHttpServerConfiguration.FileTypeHandlerConfigurationAllows configuration of properties for theFileTypeHandler.static classNettyHttpServerConfiguration.Http2SettingsHttp2 settings.static classNettyHttpServerConfiguration.NettyListenerConfigurationNetty listener configuration.static classNettyHttpServerConfiguration.ParentConfiguration for Netty parent.static classNettyHttpServerConfiguration.WorkerConfiguration for Netty worker.-
Nested classes/interfaces inherited from class io.micronaut.http.server.HttpServerConfiguration
io.micronaut.http.server.HttpServerConfiguration.CorsConfiguration, io.micronaut.http.server.HttpServerConfiguration.HostResolutionConfiguration, io.micronaut.http.server.HttpServerConfiguration.HttpLocaleResolutionConfigurationProperties, io.micronaut.http.server.HttpServerConfiguration.MultipartConfiguration
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_CHUNKSUPPORTEDThe default chunk supported value.static intDEFAULT_COMPRESSIONLEVELThe default compression level.static intDEFAULT_COMPRESSIONTHRESHOLDThe default compression threshold.static intDEFAULT_INITIALBUFFERSIZEThe default initial buffer size value.static booleanDEFAULT_KEEP_ALIVE_ON_SERVER_ERRORThe default configuration for boolean flag indicating whether to add connection header `keep-alive` to responses with HttpStatus > 499.static intDEFAULT_MAXCHUNKSIZEThe default max chunk size.static intDEFAULT_MAXHEADERSIZEThe default max header size.static intDEFAULT_MAXINITIALLINELENGTHThe default max initial line length.static booleanDEFAULT_USE_NATIVE_TRANSPORTThe default use netty's native transport flag.static booleanDEFAULT_VALIDATEHEADERSThe default validate headers value.-
Fields inherited from class io.micronaut.http.server.HttpServerConfiguration
DEFAULT_DATEHEADER, DEFAULT_DUAL_PROTOCOL, DEFAULT_HTTP_TO_HTTPS_REDIRECT, DEFAULT_IDLE_TIME_MINUTES, DEFAULT_LOG_HANDLED_EXCEPTIONS, DEFAULT_MAX_REQUEST_SIZE, DEFAULT_PORT, DEFAULT_RANDOM_PORT, DEFAULT_READ_IDLE_TIME_MINUTES, DEFAULT_WRITE_IDLE_TIME_MINUTES, PREFIX
-
-
Constructor Summary
Constructors Constructor Description NettyHttpServerConfiguration()Default empty constructor.NettyHttpServerConfiguration(io.micronaut.runtime.ApplicationConfiguration applicationConfiguration)NettyHttpServerConfiguration(io.micronaut.runtime.ApplicationConfiguration applicationConfiguration, java.util.List<io.micronaut.http.netty.channel.ChannelPipelineListener> pipelineCustomizers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NettyHttpServerConfiguration.AccessLoggergetAccessLogger()Returns the AccessLogger configuration.java.util.Map<io.netty.channel.ChannelOption,java.lang.Object>getChildOptions()intgetCompressionLevel()The default compression level.intgetCompressionThreshold()The default compression threshold.java.lang.StringgetFallbackProtocol()NettyHttpServerConfiguration.FileTypeHandlerConfigurationgetFileTypeHandlerConfiguration()NettyHttpServerConfiguration.Http2SettingsgetHttp2()Returns the Http2Settings.intgetInitialBufferSize()The initial buffer size.java.util.List<NettyHttpServerConfiguration.NettyListenerConfiguration>getListeners()Get the explicit netty listener configurations, ornullif they should be implicit.java.util.Optional<io.netty.handler.logging.LogLevel>getLogLevel()The serverLogLevelto enable.intgetMaxChunkSize()The maximum chunk size.intgetMaxH2cUpgradeRequestSize()The maximum size of the body of the HTTP1.1 request used to upgrade a connection to HTTP2 clear-text (h2c).intgetMaxHeaderSize()The maximum size of an individual HTTP setter.intgetMaxInitialLineLength()The maximum length of the initial HTTP request line.java.util.Map<io.netty.channel.ChannelOption,java.lang.Object>getOptions()NettyHttpServerConfiguration.ParentgetParent()java.lang.StringgetPcapLoggingPathPattern()The path pattern to use for logging incoming connections to pcap.java.util.List<io.micronaut.http.netty.channel.ChannelPipelineListener>getPipelineCustomizers()NettyHttpServerConfiguration.WorkergetWorker()booleanisChunkedSupported()Whether chunked requests are supported.booleanisKeepAliveOnServerError()booleanisUseNativeTransport()Whether to use netty's native transport (epoll or kqueue) if available.booleanisValidateHeaders()Whether to validate headers.voidsetAccessLogger(NettyHttpServerConfiguration.AccessLogger accessLogger)Sets the AccessLogger configuration.voidsetChildOptions(java.util.Map<io.netty.channel.ChannelOption,java.lang.Object> childOptions)Sets the Netty child worker options.voidsetChunkedSupported(boolean chunkedSupported)Sets whether chunked transfer encoding is supported.voidsetCompressionLevel(int compressionLevel)Sets the compression level (0-9).voidsetCompressionThreshold(int compressionThreshold)Sets the minimum size of a request body must be in order to be compressed.voidsetFallbackProtocol(java.lang.String fallbackProtocol)Sets the fallback protocol to use when negotiating via ALPN.voidsetFileTypeHandlerConfiguration(NettyHttpServerConfiguration.FileTypeHandlerConfiguration fileTypeHandlerConfiguration)Sets the file type handler configuration.voidsetHttp2(NettyHttpServerConfiguration.Http2Settings http2)Sets the Http2Settings.voidsetInitialBufferSize(int initialBufferSize)Sets the initial buffer size.voidsetKeepAliveOnServerError(boolean keepAliveOnServerError)Whether to send connection keep alive on internal server errors.voidsetListeners(java.util.List<NettyHttpServerConfiguration.NettyListenerConfiguration> listeners)Set the explicit netty listener configurations, ornullif they should be implicit.voidsetLogLevel(io.netty.handler.logging.LogLevel logLevel)Sets the Netty log level.voidsetMaxChunkSize(int maxChunkSize)Sets the maximum size of any single request chunk.voidsetMaxH2cUpgradeRequestSize(int maxH2cUpgradeRequestSize)Sets the maximum size of the body of the HTTP1.1 request used to upgrade a connection to HTTP2 clear-text (h2c).voidsetMaxHeaderSize(int maxHeaderSize)Sets the maximum size of any one header.voidsetMaxInitialLineLength(int maxInitialLineLength)Sets the maximum initial line length for the HTTP request.voidsetOptions(java.util.Map<io.netty.channel.ChannelOption,java.lang.Object> options)Sets the channel options.voidsetParent(NettyHttpServerConfiguration.Parent parent)Sets the parent event loop configuration.voidsetPcapLoggingPathPattern(java.lang.String pcapLoggingPathPattern)The path pattern to use for logging incoming connections to pcap.voidsetUseNativeTransport(boolean useNativeTransport)Sets whether to use netty's native transport (epoll or kqueue) if available .voidsetValidateHeaders(boolean validateHeaders)Sets whether to validate incoming headers.voidsetWorker(NettyHttpServerConfiguration.Worker worker)Sets the worker event loop configuration.-
Methods inherited from class io.micronaut.http.server.HttpServerConfiguration
getApplicationConfiguration, getClientAddressHeader, getContextPath, getCors, getDefaultCharset, getHost, getHostResolution, getHttpVersion, getIdleTimeout, getLocaleResolution, getMaxRequestSize, getMultipart, getPort, getReadIdleTimeout, getReadTimeout, getServerHeader, getThreadSelection, getWriteIdleTimeout, isDateHeader, isDualProtocol, isHttpToHttpsRedirect, isLogHandledExceptions, setClientAddressHeader, setContextPath, setCors, setDateHeader, setDefaultCharset, setDualProtocol, setHost, setHostResolution, setHttpToHttpsRedirect, setHttpVersion, setIdleTimeout, setLocaleResolution, setLogHandledExceptions, setMaxRequestSize, setMultipart, setPort, setReadIdleTimeout, setReadTimeout, setServerHeader, setThreadSelection, setWriteIdleTimeout
-
-
-
-
Field Detail
-
DEFAULT_USE_NATIVE_TRANSPORT
public static final boolean DEFAULT_USE_NATIVE_TRANSPORT
The default use netty's native transport flag.- See Also:
- Constant Field Values
-
DEFAULT_MAXINITIALLINELENGTH
public static final int DEFAULT_MAXINITIALLINELENGTH
The default max initial line length.- See Also:
- Constant Field Values
-
DEFAULT_MAXHEADERSIZE
public static final int DEFAULT_MAXHEADERSIZE
The default max header size.- See Also:
- Constant Field Values
-
DEFAULT_MAXCHUNKSIZE
public static final int DEFAULT_MAXCHUNKSIZE
The default max chunk size.- See Also:
- Constant Field Values
-
DEFAULT_CHUNKSUPPORTED
public static final boolean DEFAULT_CHUNKSUPPORTED
The default chunk supported value.- See Also:
- Constant Field Values
-
DEFAULT_VALIDATEHEADERS
public static final boolean DEFAULT_VALIDATEHEADERS
The default validate headers value.- See Also:
- Constant Field Values
-
DEFAULT_INITIALBUFFERSIZE
public static final int DEFAULT_INITIALBUFFERSIZE
The default initial buffer size value.- See Also:
- Constant Field Values
-
DEFAULT_COMPRESSIONTHRESHOLD
public static final int DEFAULT_COMPRESSIONTHRESHOLD
The default compression threshold.- See Also:
- Constant Field Values
-
DEFAULT_COMPRESSIONLEVEL
public static final int DEFAULT_COMPRESSIONLEVEL
The default compression level.- See Also:
- Constant Field Values
-
DEFAULT_KEEP_ALIVE_ON_SERVER_ERROR
public static final boolean DEFAULT_KEEP_ALIVE_ON_SERVER_ERROR
The default configuration for boolean flag indicating whether to add connection header `keep-alive` to responses with HttpStatus > 499.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NettyHttpServerConfiguration
public NettyHttpServerConfiguration()
Default empty constructor.
-
NettyHttpServerConfiguration
public NettyHttpServerConfiguration(io.micronaut.runtime.ApplicationConfiguration applicationConfiguration)
- Parameters:
applicationConfiguration- The application configuration
-
NettyHttpServerConfiguration
@Inject public NettyHttpServerConfiguration(io.micronaut.runtime.ApplicationConfiguration applicationConfiguration, java.util.List<io.micronaut.http.netty.channel.ChannelPipelineListener> pipelineCustomizers)- Parameters:
applicationConfiguration- The application configurationpipelineCustomizers- A list of pipeline customizers
-
-
Method Detail
-
getAccessLogger
public NettyHttpServerConfiguration.AccessLogger getAccessLogger()
Returns the AccessLogger configuration.- Returns:
- The AccessLogger configuration.
-
setAccessLogger
public void setAccessLogger(NettyHttpServerConfiguration.AccessLogger accessLogger)
Sets the AccessLogger configuration.- Parameters:
accessLogger- The configuration .
-
getHttp2
public NettyHttpServerConfiguration.Http2Settings getHttp2()
Returns the Http2Settings.- Returns:
- The Http2Settings.
-
setHttp2
public void setHttp2(NettyHttpServerConfiguration.Http2Settings http2)
Sets the Http2Settings.- Parameters:
http2- The Http2Settings.
-
getPipelineCustomizers
public java.util.List<io.micronaut.http.netty.channel.ChannelPipelineListener> getPipelineCustomizers()
- Returns:
- The pipeline customizers
-
getFallbackProtocol
public java.lang.String getFallbackProtocol()
- Returns:
- The fallback protocol to use when negotiating via ALPN
- See Also:
ApplicationProtocolNames
-
setFallbackProtocol
public void setFallbackProtocol(java.lang.String fallbackProtocol)
Sets the fallback protocol to use when negotiating via ALPN.- Parameters:
fallbackProtocol- The fallback protocol to use when negotiating via ALPN- See Also:
ApplicationProtocolNames
-
getLogLevel
public java.util.Optional<io.netty.handler.logging.LogLevel> getLogLevel()
The serverLogLevelto enable.- Returns:
- The server
LogLevelto enable
-
getMaxInitialLineLength
public int getMaxInitialLineLength()
The maximum length of the initial HTTP request line. Defaults to 4096.- Returns:
- The maximum length of the initial HTTP request line
-
getMaxHeaderSize
public int getMaxHeaderSize()
The maximum size of an individual HTTP setter. Defaults to 8192.- Returns:
- The maximum size of an individual HTTP setter
-
getMaxChunkSize
public int getMaxChunkSize()
The maximum chunk size. Defaults to 8192.- Returns:
- The maximum chunk size
-
getMaxH2cUpgradeRequestSize
public int getMaxH2cUpgradeRequestSize()
The maximum size of the body of the HTTP1.1 request used to upgrade a connection to HTTP2 clear-text (h2c). This initial request cannot be streamed and is instead buffered in full, so the default value (8192) is relatively small. If this value is too small for your use case, instead consider using an empty initial "upgrade request" (e.g.OPTIONS /), or switch to normal HTTP2.Does not affect normal HTTP2 (TLS).
- Returns:
- The maximum content length of the request.
-
isChunkedSupported
public boolean isChunkedSupported()
Whether chunked requests are supported.- Returns:
- Whether chunked requests are supported.
-
isUseNativeTransport
public boolean isUseNativeTransport()
Whether to use netty's native transport (epoll or kqueue) if available.- Returns:
- To use netty's native transport (epoll or kqueue) if available.
-
isValidateHeaders
public boolean isValidateHeaders()
Whether to validate headers.- Returns:
- Whether to validate headers
-
getInitialBufferSize
public int getInitialBufferSize()
The initial buffer size. Defaults to 128.- Returns:
- The initial buffer size.
-
getCompressionThreshold
public int getCompressionThreshold()
The default compression threshold. Defaults to 1024.- Returns:
- The compression threshold.
-
getCompressionLevel
public int getCompressionLevel()
The default compression level. Default value (6).- Returns:
- The compression level.
-
getChildOptions
public java.util.Map<io.netty.channel.ChannelOption,java.lang.Object> getChildOptions()
- Returns:
- The Netty child channel options.
- See Also:
ServerBootstrap.childOption(io.netty.channel.ChannelOption, Object)
-
getOptions
public java.util.Map<io.netty.channel.ChannelOption,java.lang.Object> getOptions()
- Returns:
- The Netty channel options.
- See Also:
ServerBootstrap.childOption(io.netty.channel.ChannelOption, Object)
-
getWorker
public NettyHttpServerConfiguration.Worker getWorker()
- Returns:
- Configuration for the worker
EventLoopGroup
-
getFileTypeHandlerConfiguration
@NonNull public NettyHttpServerConfiguration.FileTypeHandlerConfiguration getFileTypeHandlerConfiguration()
- Returns:
- The file type handler configuration.
- Since:
- 3.1.0
-
setFileTypeHandlerConfiguration
@Inject public void setFileTypeHandlerConfiguration(@NonNull NettyHttpServerConfiguration.FileTypeHandlerConfiguration fileTypeHandlerConfiguration)Sets the file type handler configuration.- Parameters:
fileTypeHandlerConfiguration- The file type handler configuration- Since:
- 3.1.0
-
getParent
public NettyHttpServerConfiguration.Parent getParent()
- Returns:
- Configuration for the parent
EventLoopGroup
-
isKeepAliveOnServerError
public boolean isKeepAliveOnServerError()
- Returns:
- True if the connection should be kept alive on internal server errors
-
setChildOptions
public void setChildOptions(java.util.Map<io.netty.channel.ChannelOption,java.lang.Object> childOptions)
Sets the Netty child worker options.- Parameters:
childOptions- The options
-
setOptions
public void setOptions(java.util.Map<io.netty.channel.ChannelOption,java.lang.Object> options)
Sets the channel options.- Parameters:
options- The channel options
-
setWorker
public void setWorker(NettyHttpServerConfiguration.Worker worker)
Sets the worker event loop configuration.- Parameters:
worker- The worker config
-
setParent
public void setParent(NettyHttpServerConfiguration.Parent parent)
Sets the parent event loop configuration.- Parameters:
parent- The parent config
-
setMaxInitialLineLength
public void setMaxInitialLineLength(@ReadableBytes int maxInitialLineLength)Sets the maximum initial line length for the HTTP request. Default value (4096).- Parameters:
maxInitialLineLength- The max length
-
setMaxHeaderSize
public void setMaxHeaderSize(@ReadableBytes int maxHeaderSize)Sets the maximum size of any one header. Default value (8192).- Parameters:
maxHeaderSize- The max header size
-
setMaxChunkSize
public void setMaxChunkSize(@ReadableBytes int maxChunkSize)Sets the maximum size of any single request chunk. Default value (8192).- Parameters:
maxChunkSize- The max chunk size
-
setMaxH2cUpgradeRequestSize
public void setMaxH2cUpgradeRequestSize(int maxH2cUpgradeRequestSize)
Sets the maximum size of the body of the HTTP1.1 request used to upgrade a connection to HTTP2 clear-text (h2c). This initial request cannot be streamed and is instead buffered in full, so the default value (8192) is relatively small. If this value is too small for your use case, instead consider using an empty initial "upgrade request" (e.g.OPTIONS /), or switch to normal HTTP2.Does not affect normal HTTP2 (TLS).
- Parameters:
maxH2cUpgradeRequestSize- The maximum content length of the request.
-
setChunkedSupported
public void setChunkedSupported(boolean chunkedSupported)
Sets whether chunked transfer encoding is supported. Default value (true).- Parameters:
chunkedSupported- True if it is supported
-
setUseNativeTransport
public void setUseNativeTransport(boolean useNativeTransport)
Sets whether to use netty's native transport (epoll or kqueue) if available . Default value (false).- Parameters:
useNativeTransport- True if netty's native transport should be use if available.
-
setValidateHeaders
public void setValidateHeaders(boolean validateHeaders)
Sets whether to validate incoming headers. Default value (true).- Parameters:
validateHeaders- True if headers should be validated.
-
setInitialBufferSize
public void setInitialBufferSize(int initialBufferSize)
Sets the initial buffer size. Default value (128).- Parameters:
initialBufferSize- The initial buffer size
-
setLogLevel
public void setLogLevel(io.netty.handler.logging.LogLevel logLevel)
Sets the Netty log level.- Parameters:
logLevel- The log level
-
setCompressionThreshold
public void setCompressionThreshold(@ReadableBytes int compressionThreshold)Sets the minimum size of a request body must be in order to be compressed. Default value (1024).- Parameters:
compressionThreshold- The size request bodies must be in order to be a candidate for compression.
-
setCompressionLevel
public void setCompressionLevel(@ReadableBytes int compressionLevel)Sets the compression level (0-9). Default value (6).- Parameters:
compressionLevel- The compression level.
-
setKeepAliveOnServerError
public void setKeepAliveOnServerError(boolean keepAliveOnServerError)
Whether to send connection keep alive on internal server errors. Default value (false).- Parameters:
keepAliveOnServerError- The keep alive on server error flag
-
getPcapLoggingPathPattern
@Internal public java.lang.String getPcapLoggingPathPattern()
The path pattern to use for logging incoming connections to pcap. This is an unsupported option: Behavior may change, or it may disappear entirely, without notice!- Returns:
- The path pattern, or
nullif logging is disabled.
-
setPcapLoggingPathPattern
@Internal public void setPcapLoggingPathPattern(java.lang.String pcapLoggingPathPattern)
The path pattern to use for logging incoming connections to pcap. This is an unsupported option: Behavior may change, or it may disappear entirely, without notice!- Parameters:
pcapLoggingPathPattern- The path pattern, ornullto disable logging.
-
getListeners
public java.util.List<NettyHttpServerConfiguration.NettyListenerConfiguration> getListeners()
Get the explicit netty listener configurations, ornullif they should be implicit.- Returns:
- The listeners
-
setListeners
public void setListeners(java.util.List<NettyHttpServerConfiguration.NettyListenerConfiguration> listeners)
Set the explicit netty listener configurations, ornullif they should be implicit.- Parameters:
listeners- The listeners
-
-