Commit eace762 1 parent a6a3881 commit eace762 Copy full SHA for eace762
File tree 1 file changed +7
-4
lines changed
packages/serverpod/lib/src/server
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -428,15 +428,18 @@ class Server {
428
428
}
429
429
430
430
Future <String > _readBody (HttpRequest request) async {
431
- var builder = BytesBuilder ();
431
+ var builder = BytesBuilder (copy : false );
432
432
var len = 0 ;
433
+ var tooLarge = false ;
433
434
await for (var segment in request) {
434
435
len += segment.length;
435
- if (len > serverpod.config.maxRequestSize) {
436
- throw _RequestTooLargeException (serverpod.config.maxRequestSize);
437
- }
436
+ if (tooLarge) continue ; // ensure we drain the request stream regardless
437
+ if (len > serverpod.config.maxRequestSize) tooLarge = true ;
438
438
builder.add (segment);
439
439
}
440
+ if (tooLarge) {
441
+ throw _RequestTooLargeException (serverpod.config.maxRequestSize);
442
+ }
440
443
return const Utf8Decoder ().convert (builder.toBytes ());
441
444
}
442
445
You can’t perform that action at this time.
0 commit comments