File tree Expand file tree Collapse file tree
modules/jooby-jetty/src/main/java/io/jooby/internal/jetty Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -460,6 +460,9 @@ public int getMaxRequestSize() {
460460 * @return This options.
461461 */
462462 public ServerOptions setMaxRequestSize (int maxRequestSize ) {
463+ if (maxRequestSize <= 0 ) {
464+ throw new IllegalArgumentException ("maxRequestSize must be greater than 0" );
465+ }
463466 this .maxRequestSize = maxRequestSize ;
464467 this .defaults = false ;
465468 return this ;
Original file line number Diff line number Diff line change @@ -274,6 +274,15 @@ void testPackagePrivateConstructor() {
274274 assertTrue (options .defaults );
275275 }
276276
277+ @ Test
278+ @ DisplayName (
279+ "MaxRequestSize setter should throw IllegalArgumentException for non-positive values" )
280+ void testMaxRequestSizeSetterThrows () {
281+ ServerOptions options = new ServerOptions ();
282+ assertThrows (IllegalArgumentException .class , () -> options .setMaxRequestSize (0 ));
283+ assertThrows (IllegalArgumentException .class , () -> options .setMaxRequestSize (-1 ));
284+ }
285+
277286 @ Test
278287 public void settersShouldClearDefaultsFlag () {
279288 assertSetterClearsDefault (options -> options .setServer ("Netty" ));
Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ public Body body() {
150150 }
151151 InputStream in = Content .Source .asInputStream (request );
152152 long len = request .getLength ();
153- if (maxRequestSize > 0 ) {
153+ if (len >= maxRequestSize ) {
154154 in = new LimitedInputStream (in , maxRequestSize );
155155 }
156156 return Body .of (this , in , len );
You can’t perform that action at this time.
0 commit comments