Class 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.HttpServerConfiguration
    Allows configuring Netty within NettyHttpServer.
    Since:
    1.0
    • 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 configuration
        pipelineCustomizers - A list of pipeline customizers
    • Method Detail

      • 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 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 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)
      • 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
      • 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
      • 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 null if 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, or null to disable logging.