readBytes static method
read the whole body, but stop with 413 once it passes max bytes.
Implementation
static Future<Uint8List> readBytes(HttpRequest request, int max) async {
_checkContentLength(request, max);
/// the server holds the whole body already, or reads a big one in one
/// buffer outside the Dart heap: no stream needed.
Future<Uint8List>? whole = DoxServer.adapter.readBody(request, max);
if (whole != null) return whole;
BytesBuilder builder = BytesBuilder(copy: false);
await for (List<int> chunk in limit(request, max)) {
builder.add(chunk);
}
return builder.takeBytes();
}