Class NettyHttpServerConfiguration

java.lang.Object
io.micronaut.http.server.HttpServerConfiguration
io.micronaut.http.server.netty.configuration.NettyHttpServerConfiguration
All Implemented Interfaces:
ServerContextPathProvider

@ConfigurationProperties("netty") @Replaces(HttpServerConfiguration.class) public class NettyHttpServerConfiguration extends HttpServerConfiguration
Allows configuring Netty within NettyHttpServer.
Since:
1.0
Author:
Graeme Rocher
  • Field Details

    • DEFAULT_USE_NATIVE_TRANSPORT

      public static final boolean DEFAULT_USE_NATIVE_TRANSPORT
      The default use netty's native transport flag.
      See Also:
    • DEFAULT_MAXINITIALLINELENGTH

      public static final int DEFAULT_MAXINITIALLINELENGTH
      The default max initial line length.
      See Also:
    • DEFAULT_MAXHEADERSIZE

      public static final int DEFAULT_MAXHEADERSIZE
      The default max header size.
      See Also:
    • DEFAULT_MAXCHUNKSIZE

      public static final int DEFAULT_MAXCHUNKSIZE
      The default max chunk size.
      See Also:
    • DEFAULT_CHUNKSUPPORTED

      public static final boolean DEFAULT_CHUNKSUPPORTED
      The default chunk supported value.
      See Also:
    • DEFAULT_VALIDATEHEADERS

      public static final boolean DEFAULT_VALIDATEHEADERS
      The default validate headers value.
      See Also:
    • DEFAULT_INITIALBUFFERSIZE

      public static final int DEFAULT_INITIALBUFFERSIZE
      The default initial buffer size value.
      See Also:
    • DEFAULT_COMPRESSIONTHRESHOLD

      public static final int DEFAULT_COMPRESSIONTHRESHOLD
      The default compression threshold.
      See Also:
    • DEFAULT_COMPRESSIONLEVEL

      public static final int DEFAULT_COMPRESSIONLEVEL
      The default compression level.
      See Also:
    • 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:
  • Constructor Details

    • NettyHttpServerConfiguration

      public NettyHttpServerConfiguration()
      Default empty constructor.
    • NettyHttpServerConfiguration

      public NettyHttpServerConfiguration(ApplicationConfiguration applicationConfiguration)
      Parameters:
      applicationConfiguration - The application configuration
    • NettyHttpServerConfiguration

      @Inject public NettyHttpServerConfiguration(ApplicationConfiguration applicationConfiguration, List<ChannelPipelineListener> pipelineCustomizers)
      Parameters:
      applicationConfiguration - The application configuration
      pipelineCustomizers - A list of pipeline customizers
  • Method Details

    • 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

      Returns the Http2Settings.
      Returns:
      The Http2Settings.
    • setHttp2

      public void setHttp2(NettyHttpServerConfiguration.Http2Settings http2)
      Sets the Http2Settings.
      Parameters:
      http2 - The Http2Settings.
    • getPipelineCustomizers

      public List<ChannelPipelineListener> getPipelineCustomizers()
      Returns:
      The pipeline customizers
    • getFallbackProtocol

      public String getFallbackProtocol()
      Returns:
      The fallback protocol to use when negotiating via ALPN
      See Also:
      • ApplicationProtocolNames
    • setFallbackProtocol

      public void setFallbackProtocol(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 Optional<io.netty.handler.logging.LogLevel> getLogLevel()
      The server LogLevel to enable.
      Returns:
      The server LogLevel to 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 Map<io.netty.channel.ChannelOption,Object> getChildOptions()
      Returns:
      The Netty child channel options.
      See Also:
      • ServerBootstrap.childOption(io.netty.channel.ChannelOption, Object)
    • getOptions

      public Map<io.netty.channel.ChannelOption,Object> getOptions()
      Returns:
      The Netty channel options.
      See Also:
      • ServerBootstrap.childOption(io.netty.channel.ChannelOption, Object)
    • 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

      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(Map<io.netty.channel.ChannelOption,Object> childOptions)
      Sets the Netty child worker options.
      Parameters:
      childOptions - The options
    • setOptions

      public void setOptions(Map<io.netty.channel.ChannelOption,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 (true).
      Parameters:
      keepAliveOnServerError - The keep alive on server error flag
    • getPcapLoggingPathPattern

      @Internal public 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 null if logging is disabled.
    • setPcapLoggingPathPattern

      @Internal public void setPcapLoggingPathPattern(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, or null to disable logging.
    • getListeners

      Get the explicit netty listener configurations, or null if they should be implicit.
      Returns:
      The listeners
    • setListeners

      public void setListeners(List<NettyHttpServerConfiguration.NettyListenerConfiguration> listeners)
      Set the explicit netty listener configurations, or null if they should be implicit.
      Parameters:
      listeners - The listeners