limit static method
pass the body through, but throw 413 once it passes max bytes.
this catches clients that lie about or skip Content-Length.
Implementation
static Stream<List<int>> limit(Stream<List<int>> body, int max) async* {
int total = 0;
await for (List<int> chunk in body) {
total += chunk.length;
if (total > max) throw PayloadTooLargeException();
yield chunk;
}
}