title: WebFlux DataBufferLimitException: Part headers exceeded the memory usage limit of 8192 bytes
body: <p>When uploading a csv file and a JSON object at the following endpoint</p>
  <pre><code>@PostMapping(value = &quot;dataset/rows/query&quot;, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
  Mono&lt;List&lt;Integer&gt;&gt; getRowsByQuery(@RequestPart(&quot;dataset&quot;) Mono&lt;FilePart&gt; file, 
                                     @RequestPart(&quot;query&quot;) QueryDTO query){
      return Mono.just(new ArrayList&lt;&gt;());
  }
  </code></pre>
  <p>I get the following error:</p>
  <pre><code>2020-12-17 12:25:05.142 ERROR 195281 --- [or-http-epoll-3] a.w.r.e.AbstractErrorWebExceptionHandler : [d418565e-17]  500 Server Error for HTTP POST &quot;/dataset/rows/query&quot;
  
  org.springframework.core.io.buffer.DataBufferLimitException: Part headers exceeded the memory usage limit of 8192 bytes
      at org.springframework.http.codec.multipart.MultipartParser$HeadersState.onNext(MultipartParser.java:360) ~[spring-web-5.3.1.jar:5.3.1]
      Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
  Error has been observed at the following site(s):
      |_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
      |_ checkpoint ⇢ HTTP POST &quot;/dataset/rows/query&quot; [ExceptionHandlingWebHandler]
  Stack trace:
          at org.springframework.http.codec.multipart.MultipartParser$HeadersState.onNext(MultipartParser.java:360) ~[spring-web-5.3.1.jar:5.3.1]
          at org.springframework.http.codec.multipart.MultipartParser.hookOnNext(MultipartParser.java:104) ~[spring-web-5.3.1.jar:5.3.1]
          at org.springframework.http.codec.multipart.MultipartParser.hookOnNext(MultipartParser.java:46) ~[spring-web-5.3.1.jar:5.3.1]
          at reactor.core.publisher.BaseSubscriber.onNext(BaseSubscriber.java:160) ~[reactor-core-3.4.0.jar:3.4.0]
          at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120) ~[reactor-core-3.4.0.jar:3.4.0]
          at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:199) ~[reactor-core-3.4.0.jar:3.4.0]
          at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120) ~[reactor-core-3.4.0.jar:3.4.0]
          at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:265) ~[reactor-netty-core-1.0.1.jar:1.0.1]
          at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:371) ~[reactor-netty-core-1.0.1.jar:1.0.1]
          at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:381) ~[reactor-netty-core-1.0.1.jar:1.0.1]
          at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:535) ~[reactor-netty-http-1.0.1.jar:1.0.1]
          at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:94) ~[reactor-netty-core-1.0.1.jar:1.0.1]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:229) ~[reactor-netty-http-1.0.1.jar:1.0.1]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) ~[netty-codec-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311) ~[netty-codec-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:425) ~[netty-codec-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) ~[netty-codec-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) ~[netty-transport-native-epoll-4.1.54.Final-linux-x86_64.jar:4.1.54.Final]
          at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480) ~[netty-transport-native-epoll-4.1.54.Final-linux-x86_64.jar:4.1.54.Final]
          at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) ~[netty-transport-native-epoll-4.1.54.Final-linux-x86_64.jar:4.1.54.Final]
          at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.54.Final.jar:4.1.54.Final]
          at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.54.Final.jar:4.1.54.Final]
          at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
  </code></pre>
  <p>I tried to customize the <code>defaultCodex().maxinMemorySize()</code> by</p>
  <pre><code>@Component
  public class ServerConfiguration implements WebFluxConfigurer {
      @Override
      public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
          configurer.defaultCodecs().maxInMemorySize(16 * 1024 * 1024);
      }
  }
  </code></pre>
  <p>and the following application.yml</p>
  <pre><code>server:
    port: ${SERVER_PORT:8080}
    max-http-header-size: 900000000
  spring:
    codec:
      max-in-memory-size: 900000000
  </code></pre>
  <p>but it doesn't seem to have any effect.</p>
  <p>Moreover, what is strange is that the error on the server side only seems to happen when calling the API from Angular, but not from postman.</p>
  <p>From <strong>Angular</strong> I have the following headers:</p>
  <pre><code>POST /dataset/rows/query HTTP/1.1
  Host: localhost:4200
  Connection: keep-alive
  Content-Length: 496570
  Pragma: no-cache
  Cache-Control: no-cache
  Accept: */*
  DNT: 1
  User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36
  Content-Type: multipart/form-data; boundary=----WebKitFormBoundarySBh6gJvnTeDzB43Y
  Origin: http://localhost:4200
  Sec-Fetch-Site: same-origin
  Sec-Fetch-Mode: cors
  Sec-Fetch-Dest: empty
  Referer: http://localhost:4200/app
  Accept-Encoding: gzip, deflate, br
  Accept-Language: it-IT,it;q=0.9,en-GB;q=0.8,en;q=0.7,ru-RU;q=0.6,ru;q=0.5,en-US;q=0.4
  </code></pre>
  <p>and finally, this is the corresponding OpenAPI yaml for the endpoint:</p>
  <pre><code>openapi: 3.0.1
  info:
    title: OpenAPI definition
    version: v0
  servers:
  - url: http://localhost:8080
    description: Generated server url
  paths:
    /dataset/rows/query:
      post:
        tags:
        - dataset-controller
        operationId: getRowsByQuery
        requestBody:
          content:
            multipart/form-data:
              schema:
                type: object
                properties:
                  dataset:
                    type: string
                    format: binary
                  query:
                    $ref: '#/components/schemas/QueryDTO'
        responses:
          &quot;200&quot;:
            description: OK
            content:
              '*/*':
                schema:
                  type: array
                  items:
                    type: integer
                    format: int32
  components:
    schemas:
      PredicateDTO:
        type: object
        properties:
          value:
            type: object
          key:
            type: string
          operator:
            type: string
            enum:
            - EQUAL
            - NOT_EQUAL
            - BELONGING
            - NOT_BELONGING
            - GREATER_THAN
            - GREATER_THAN_EQUAL
            - LESS_THAN
            - LESS_THAN_EQUAL
      QueryDTO:
        type: object
        properties:
          predicates:
            type: object
            additionalProperties:
              $ref: '#/components/schemas/PredicateDTO'
  </code></pre>
  <p>Here is my <a href="https://pastebin.com/raw/QuethDg6" rel="noreferrer">dataset</a> and my <a href="https://pastebin.com/raw/qBRGxLJr" rel="noreferrer">json object</a>.
  How can I increase the Part headers memory usage limit?</p>