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

  • 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

    • getServerType

      Returns:
      Sets the server type.
      See Also:
    • isCloseOnExpectationFailed

      public boolean isCloseOnExpectationFailed()
      If a 100-continue response is detected but the content length is too large then true means close the connection. otherwise the connection will remain open and data will be consumed and discarded until the next request is received.

      only relevant when NettyHttpServerConfiguration.HttpServerType.FULL_CONTENT is set

      Returns:
      True if the connection should be closed
      See Also:
    • setCloseOnExpectationFailed

      public void setCloseOnExpectationFailed(boolean closeOnExpectationFailed)
      If a 100-continue response is detected but the content length is too large then true means close the connection. otherwise the connection will remain open and data will be consumed and discarded until the next request is received.

      only relevant when NettyHttpServerConfiguration.HttpServerType.FULL_CONTENT is set

      Parameters:
      closeOnExpectationFailed - True if the connection should be closed
      See Also:
    • setServerType

      public void setServerType(@Nullable @Nullable NettyHttpServerConfiguration.HttpServerType serverType)
      Set the server type.
      Parameters:
      serverType - The server type
    • 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.
    • getHttp3

      Returns the Http3Settings.
      Returns:
      The Http3Settings.
    • setHttp3Settings

      public void setHttp3Settings(NettyHttpServerConfiguration.Http3Settings http3Settings)
      Sets the Http3Settings.
      Parameters:
      http3Settings - The Http3Settings.
    • 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

      Returns:
      The file type handler configuration.
      Since:
      3.1.0
    • setFileTypeHandlerConfiguration

      @Inject public void setFileTypeHandlerConfiguration(@NonNull @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
    • isEagerParsing

      public boolean isEagerParsing()
      Parse incoming JSON data eagerly, before route binding. Default value false.
      Returns:
      Whether to parse incoming JSON data eagerly before route binding
      Since:
      4.0.0
    • setEagerParsing

      public void setEagerParsing(boolean eagerParsing)
      Parse incoming JSON data eagerly, before route binding. Default value false.
      Parameters:
      eagerParsing - Whether to parse incoming JSON data eagerly before route binding
      Since:
      4.0.0
    • getJsonBufferMaxComponents

      public int getJsonBufferMaxComponents()
      Maximum number of buffers to keep around in JSON parsing before they should be consolidated. Defaults to 4096.
      Returns:
      The maximum number of components
      Since:
      4.0.0
    • setJsonBufferMaxComponents

      public void setJsonBufferMaxComponents(int jsonBufferMaxComponents)
      Maximum number of buffers to keep around in JSON parsing before they should be consolidated. Defaults to 4096.
      Parameters:
      jsonBufferMaxComponents - The maximum number of components
      Since:
      4.0.0