Problem:

Currently NettyWebServerFactoryCustomizer support only the following parameters: - server.max-http-header-size -> HttpRequestDecoderSpec#maxHeaderSize If you want to customize any other parameters from HttpRequestDecoderSpec you need to declare a NettyServerCustomizer like:

public NettyServerCustomizer customizeHttpRequestDecoderValues() {
    return httpServer -> httpServer.httpRequestDecoder(httpRequestDecoder -> {
        return httpRequestDecoder.h2cMaxContentLength(1024)
                .maxChunkSize(4096)
                .initialBufferSize(2048)
                .maxHeaderSize(4096);
    });
}

However NettyWebServerFactoryCustomize#customize is invoked in WebServerFactoryCustomizerBeanPostProcessor after NettyServerCustomizer have been injected in the NettyReactiveWebServerFactory therefore the customization provided by NettyWebServerFactoryCustomize are added at the end of the customizers list. Therefore they will override any customization previously registered by the user.

You end-up with the default values for all the other parameters.

Solutions:

  1. Add properties support for all the parameters available in HttpRequestDecoderSpec
  2. Change order of customizers (not sure that will possible)

Comment From: wilkinsona

If your customizations are ordering dependent, I would recommend applying them via a WebServerFactoryCustomizer<NettyReactiveWebServerFactory>. NettyWebServerFactoryCustomizer has an order of 0 so you can configure your own customiser to run before or after it as required. Does that meet your needs for now at least?

Comment From: Julien-Eyraud

Yes didn't think about it but still I think it should be possible to configure this by properties. Maybe I'll create a PR.

Comment From: wilkinsona

Agreed. https://github.com/spring-projects/spring-boot/issues/21504 is tracking that enhancement. A PR would be most welcome.