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

Max request size from multipart config is applied to all requests irrespective of content type

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.2.9.Final, 2.0.39.Final
    • 2.0.26.Final
    • Servlet
    • None
    • Hide

      The problem can be reproduced with the following code:

      package example;
      
      import java.io.IOException;
      
      import javax.servlet.MultipartConfigElement;
      import javax.servlet.ServletException;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      
      import io.undertow.Undertow;
      import io.undertow.UndertowOptions;
      import io.undertow.server.HttpHandler;
      import io.undertow.servlet.api.DeploymentInfo;
      import io.undertow.servlet.api.DeploymentManager;
      
      import static io.undertow.servlet.Servlets.defaultContainer;
      import static io.undertow.servlet.Servlets.deployment;
      import static io.undertow.servlet.Servlets.servlet;
      
      public class MaxRequestSizeConfigurationProblem {
      
      	public static void main(final String[] args) {
      		try {
      			DeploymentInfo servletBuilder = deployment()
      					.setClassLoader(MaxRequestSizeConfigurationProblem.class.getClassLoader()).setContextPath("/")
      					.setDeploymentName("test.war")
      					.addServlets(servlet("TestServlet", TestServlet.class).addMapping("/*").setMultipartConfig(
      							new MultipartConfigElement(System.getProperty("java.io.tmpdir"), 10, 20, 10)));
      			DeploymentManager manager = defaultContainer().addDeployment(servletBuilder);
      			manager.deploy();
      			HttpHandler servletHandler = manager.start();
      			Undertow server = Undertow.builder().setServerOption(UndertowOptions.MAX_ENTITY_SIZE, 200L)
      					.addHttpListener(8080, "localhost").setHandler(servletHandler).build();
      			server.start();
      		}
      		catch (ServletException e) {
      			throw new RuntimeException(e);
      		}
      	}
      
      	public static class TestServlet extends HttpServlet {
      
      		@Override
      		protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      			byte[] bytes = new byte[8192];
      			int read;
      			System.out.println("Content-Type: " + req.getHeader("Content-Type"));
      			while ((read = req.getInputStream().read(bytes)) > 0) {
      				System.out.println("Read " + read + " bytes");
      			}
      		}
      
      	}
      
      }
      

      POSTing 20 bytes will work as expected:

      $ curl -i -X POST localhost:8080 -d abcdefghijklmnopqrst
      HTTP/1.1 200 OK
      Connection: keep-alive
      Content-Length: 0
      Date: Mon, 14 Oct 2019 09:12:58 GMT
      

      POSTing 21 bytes or more will fail despite the max entity size being 200:

      $ curl -i -X POST localhost:8080 -d abcdefghijklmnopqrstu
      HTTP/1.1 500 Internal Server Error
      Connection: close
      Content-Type: text/html;charset=UTF-8
      Content-Length: 8982
      Date: Mon, 14 Oct 2019 09:13:58 GMT
      
      <html><head><title>ERROR</title><style>
      body {
          font-family: "Lucida Grande", "Lucida Sans Unicode", "Trebuchet MS", Helvetica, Arial, Verdana, sans-serif;
          margin: 5px;
      }
      
      .header {
          background-image: linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%);
          background-image: -o-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%);
          background-image: -moz-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%);
          background-image: -webkit-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%);
          background-image: -ms-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%);
          
          background-image: -webkit-gradient(
              linear,
              left bottom,
              left top,
              color-stop(0.08, rgb(153,151,153)),
              color-stop(0.54, rgb(199,199,199))
          );
          color: black;
          padding: 2px;
          font-weight: normal;
          border: solid 1px;
          font-size: 170%;
          text-align: left;
          vertical-align: middle; 
          height: 32px; 
          margin-bottom: 10px;
      }
      .error-div {
          display: inline-block;
          width: 32px;
          height: 32px;
          background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAgAAAAIACH+pydAAAGGElEQVRYw8WXW2wcVxnHf+fM7NXrdXbdtZ3ipGq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yNjoyNC0wNzowMC7DUNYAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTAtMDEtMTFUMDg6NTc6MzUtMDc6MDCruapPAAAAMnRFWHRMaWNlbnNlAGh0dHA6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvUHVibGljX2RvbWFpbj/96s8AAAAldEVYdG1vZGlmeS1kYXRlADIwMDktMTEtMTBUMTk6Mzg6MjQtMDc6MDArg9/WAAAAGXRFWHRTb3VyY2UAVGFuZ28gSWNvbiBMaWJyYXJ5VM/tggAAADp0RVh0U291cmNlX1VSTABodHRwOi8vdGFuZ28uZnJlZWRlc2t0b3Aub3JnL1RhbmdvX0ljb25fTGlicmFyebzIrdYAAAAASUVORK5CYII=') left center no-repeat;
      }
      .error-text-div {
          display: inline-block;
          vertical-align: top;
          height: 32px;
      }
      .label {
          font-weight:bold;
          display: inline-block;
      }
      .value {
          display: inline-block;
          margin-left: 5px;
      }
      pre {
          font-size: 110%;
          margin-left: 1.5em;
          white-space: pre-wrap;
          white-space: -moz-pre-wrap;
          white-space: -pre-wrap;
          white-space: -o-pre-wrap;
          word-wrap: break-word;
      }
      </style></head><body><div class="header"><div class="error-div"></div><div class="error-text-div">Error processing request</div></div><div class="label">Context Path:</div><div class="value"></div><br/><div class="label">Servlet Path:</div><div class="value"></div><br/><div class="label">Path Info:</div><div class="value">/</div><br/><div class="label">Query String:</div><div class="value">null</div><br/><div class="label">Stack Trace:</div><div class="value"></div><br/><pre>io.undertow.server.RequestTooBigException: UT000020: Connection terminated as request was larger than 20
      	at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168)
      	at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:229)
      	at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
      	at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209)
      	at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2343)
      	at org.xnio.channels.Channels.readBlocking(Channels.java:294)
      	at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:192)
      	at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:168)
      	at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:154)
      	at example.MaxRequestSizeConfigurationProblem$TestServlet.doPost(MaxRequestSizeConfigurationProblem.java:68)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:706)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
      	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
      	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
      	at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
      	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
      	at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
      	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
      	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
      	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
      	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
      	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
      	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)
      	at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
      	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
      	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
      	at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
      	at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
      	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
      	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
      	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
      	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
      	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      </pre></body></html>
      
      Show
      The problem can be reproduced with the following code: package example; import java.io.IOException; import javax.servlet.MultipartConfigElement; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import io.undertow.Undertow; import io.undertow.UndertowOptions; import io.undertow.server.HttpHandler; import io.undertow.servlet.api.DeploymentInfo; import io.undertow.servlet.api.DeploymentManager; import static io.undertow.servlet.Servlets.defaultContainer; import static io.undertow.servlet.Servlets.deployment; import static io.undertow.servlet.Servlets.servlet; public class MaxRequestSizeConfigurationProblem { public static void main( final String [] args) { try { DeploymentInfo servletBuilder = deployment() .setClassLoader(MaxRequestSizeConfigurationProblem. class. getClassLoader()).setContextPath( "/" ) .setDeploymentName( "test.war" ) .addServlets(servlet( "TestServlet" , TestServlet.class).addMapping( "/*" ).setMultipartConfig( new MultipartConfigElement( System .getProperty( "java.io.tmpdir" ), 10, 20, 10))); DeploymentManager manager = defaultContainer().addDeployment(servletBuilder); manager.deploy(); HttpHandler servletHandler = manager.start(); Undertow server = Undertow.builder().setServerOption(UndertowOptions.MAX_ENTITY_SIZE, 200L) .addHttpListener(8080, "localhost" ).setHandler(servletHandler).build(); server.start(); } catch (ServletException e) { throw new RuntimeException(e); } } public static class TestServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { byte [] bytes = new byte [8192]; int read; System .out.println( "Content-Type: " + req.getHeader( "Content-Type" )); while ((read = req.getInputStream().read(bytes)) > 0) { System .out.println( "Read " + read + " bytes" ); } } } } POSTing 20 bytes will work as expected: $ curl -i -X POST localhost:8080 -d abcdefghijklmnopqrst HTTP/1.1 200 OK Connection: keep-alive Content-Length: 0 Date: Mon, 14 Oct 2019 09:12:58 GMT POSTing 21 bytes or more will fail despite the max entity size being 200: $ curl -i -X POST localhost:8080 -d abcdefghijklmnopqrstu HTTP/1.1 500 Internal Server Error Connection: close Content-Type: text/html;charset=UTF-8 Content-Length: 8982 Date: Mon, 14 Oct 2019 09:13:58 GMT <html><head><title>ERROR</title><style> body { font-family: "Lucida Grande", "Lucida Sans Unicode", "Trebuchet MS", Helvetica, Arial, Verdana, sans-serif; margin: 5px; } .header { background-image: linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%); background-image: -o-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%); background-image: -moz-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%); background-image: -webkit-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%); background-image: -ms-linear-gradient(bottom, rgb(153,151,153) 8%, rgb(199,199,199) 54%); background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0.08, rgb(153,151,153)), color-stop(0.54, rgb(199,199,199)) ); color: black; padding: 2px; font-weight: normal; border: solid 1px; font-size: 170%; text-align: left; vertical-align: middle; height: 32px; margin-bottom: 10px; } .error-div { display: inline-block; width: 32px; height: 32px; background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAgAAAAIACH+pydAAAGGElEQVRYw8WXW2wcVxnHf+fM7NXrdXbdtZ3ipGqCEzvQKmlFoUggwkvvGBoaqVVV5Y0nkCoQPPCAhMQbQlzUh/IWHoh6QUVKZVLxUCGogKZRW9uJkyg0iVzZ2dhre9c7u7M7c87hYWc2M7t2bBASI306O/85+v7/7zLn24H/8yV2u/EcFNvwVNK2X0DKw1qpYaX1gCWlY0m5arRe8JQ6I2DmaVj/nwk4CxO2Zf1aw9dKo6N67+eOZHN7x0gViiSHBmlXa7hrazjLt1i+eKmxUi5bwpg/e8a8PA3X/msBr0MyJ+WvgFOffehY8v7HH5OW78HqGjgOtNrge2AnIJWAgQEYLqBsm3/NvKM/mZ1rYczpRa2/9x3w/iMBM1BCiHfuGRmZevClF9NJ5cP1m9B0+/aa3t/ZDNw3TtuSfPy737trK6sXtTGPPwOruxLwNhSEEHMHpqZGDz93wubKFdio3ZXUGNOHs2cIDh/g6pt/9G8uXLnlGPP5k1Dt5bN60m6lhXj34OTkxKET37SZm4d6oz/KgFRH7yOrBozbwlTWGf7ql6RZrWTcytrxaTj9Ro9OGb3JS/mz0nDxgYnnvmWbuUsdJ6FTY2JmImShqZA83N90UbOXOXDiG4nCcPFoTsqfbluCP8DenJQLx1/+7pBcXILaZl9qo2svFmalb48xkM9hxkf5+29+u9HSenIayn0ZyEr5i0NHpnKy7aGrtW6UehsLozRBRlRQE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S4ff6qX7297rXh9Gn4/llobMcjtsFywACQ+zZMTsOP8vBIOpNS+bFiJj2cxx7MYg+k8ZwmrWqD9lqNjVvrTc9tWRtw/k345dtwFagDTmTdUUA2EDAYXffB2JPw6FH4ch7GUpCzIemD50J9A1Y+hH/8Cc4vdTq9Tud9D9dNOt+MajclyNL53xZmIhusmcBSQJLOd4UJnHqACzTppDy0kHizl/yuPRB5nggIM0A6IE4GuA34EQFtoBUQuwGm7kbwb+eaEEXmuV5dAAAAJXRFWHRjcmVhdGUtZGF0ZQAyMDA5LTExLTEwVDE5OjM4OjI0LTA3OjAwdDKp4gAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxMC0wMi0yMFQyMzoyNjoyNC0wNzowMC7DUNYAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTAtMDEtMTFUMDg6NTc6MzUtMDc6MDCruapPAAAAMnRFWHRMaWNlbnNlAGh0dHA6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvUHVibGljX2RvbWFpbj/96s8AAAAldEVYdG1vZGlmeS1kYXRlADIwMDktMTEtMTBUMTk6Mzg6MjQtMDc6MDArg9/WAAAAGXRFWHRTb3VyY2UAVGFuZ28gSWNvbiBMaWJyYXJ5VM/tggAAADp0RVh0U291cmNlX1VSTABodHRwOi8vdGFuZ28uZnJlZWRlc2t0b3Aub3JnL1RhbmdvX0ljb25fTGlicmFyebzIrdYAAAAASUVORK5CYII=') left center no-repeat; } .error-text-div { display: inline-block; vertical-align: top; height: 32px; } .label { font-weight:bold; display: inline-block; } .value { display: inline-block; margin-left: 5px; } pre { font-size: 110%; margin-left: 1.5em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word; } </style></head><body><div class="header"><div class="error-div"></div><div class="error-text-div">Error processing request</div></div><div class="label">Context Path:</div><div class="value"></div><br/><div class="label">Servlet Path:</div><div class="value"></div><br/><div class="label">Path Info:</div><div class="value">/</div><br/><div class="label">Query String:</div><div class="value">null</div><br/><div class="label">Stack Trace:</div><div class="value"></div><br/><pre>io.undertow.server.RequestTooBigException: UT000020: Connection terminated as request was larger than 20 at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168) at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:229) at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127) at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209) at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2343) at org.xnio.channels.Channels.readBlocking(Channels.java:294) at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:192) at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:168) at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:154) at example.MaxRequestSizeConfigurationProblem$TestServlet.doPost(MaxRequestSizeConfigurationProblem.java:68) at javax.servlet.http.HttpServlet.service(HttpServlet.java:706) at javax.servlet.http.HttpServlet.service(HttpServlet.java:791) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) </pre></body></html>

      ServletInitialHandler applies any greater than zero maxRequestSize from the ManagedServlet to every exchange, irrespective of the request's content type. When the ManagedServlet has a MultipartConfigElement, its maxRequestSize is used. The net effect of this is that setting the maxRequestSize on a MultipartConfigElement affects the max request size for every request to the Servlet with which the MultipartConfigElement is associated, and not just multipart/form-data requests. This also means that any server-wide configuration of UndertowOptions.MAX_ENTITY_SIZE is overridden by configuration that should be multi-part specific.

              rhn-cservice-bbaranow Bartosz Baranowski
              ankinson Andy Wilkinson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: