readNow static method
The body, when it can be made with no wait: a JSON or urlencoded body on the native server (it holds the whole body already), or a body type that Dox does not read. null when it needs read (dart:io, or multipart). Throws 413 like read.
Implementation
static RequestBody? readNow(HttpRequest request, ContentType contentType) {
bool json = HttpBody.isJson(contentType);
bool urlEncoded = !json && HttpBody.isUrlEncoded(contentType);
if (!json && !urlEncoded) {
if (HttpBody.isFormData(contentType)) return null;
return RequestBody(<String, dynamic>{}, kind: BodyKind.other);
}
if (request is! NativeRequest) return null;
int max = Dox().config.maxBodySize;
_checkContentLength(request, max);
Uint8List bytes = request.body;
if (bytes.length > max) throw PayloadTooLargeException();
return json ? _json(bytes) : _urlEncoded(bytes);
}