Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-2614

2.3.19 breaks backward compatibility in max entity size handling.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 2.3.19.Final
    • Core
    • None

      We have services that use UndertowOptions.MAX_ENTITY_SIZE to limit the size of incoming bodies.

      Our error management handles undertow's RequestTooBigException by returning 413: Payload too large http status code.

      This does not work since upgrading to undertow version 2.3.19. Undertow automatically return 400: Bad Request }}and our error management is not notified of{{ {{RequestTooBigException}} anymore.

      After troubleshooting I found this change in 2.3.19:

      io.undertow.server.protocol.http.HttpTransferEncoding.handleRequestEncoding() method now contains in lines 126 to 129:

       

      if (exchange.getMaxEntitySize() > 0 && exchange.getMaxEntitySize() < contentLength && exchange.isResponseChannelAvailable()) {
          persistentConnection = false;
          Connectors.terminateRequest(exchange);
          throw UndertowMessages.MESSAGES.requestEntityWasTooLarge(exchange.getMaxEntitySize());
      } 

      The exception is caught in io.undertow.server.protocol.http.HttpReadListener line 267 and 400 is returned and connection closed.

       

       

      In 2.3.18 RequestTooBigException was thrown in io.undertow.conduits.FixedLengthStreamSourceConduit.requestEntityWasTooLarge(final long size) lines 166 to 173

      if (exchange.getMaxEntitySize() > 0 && exchange.getMaxEntitySize() < (state & MASK_COUNT)) {
          //max entity size is exceeded
          //we need to forcibly close the read side
          Connectors.terminateRequest(exchange);
          exchange.setPersistent(false);
          finishListener.handleEvent(this);
          this.state |= FLAG_FINISHED | FLAG_CLOSED;
          throw UndertowMessages.MESSAGES.requestEntityWasTooLarge(exchange.getMaxEntitySize());
      } 

      This allowed our error management to catch it and return 413: Payload too large.

       

       

              flaviarnn Flavia Rainone
              paskos Pascal Gehl
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: