Future<List<int>> decodeAsBytes()

Returns request body as List of bytes.

If there is no body data, this method returns null.

This method first invokes decodedData, potentially decoding the request body if there is a codec in HTTPCodecRepository for the content-type of the request.

If there is not a codec for the content-type of the request, no decoding occurs and this method returns the list of bytes directly from the request body.

If the body was decoded with a codec, this method will throw an exception by default because the raw request body bytes are discarded after decoding succeeds to free up memory. You may set retainOriginalBytes to true prior to decoding to keep a copy of the raw bytes; in which case, this method will successfully return the request body bytes.

For a non-Future variant, see asBytes.

Source

Future<List<int>> decodeAsBytes() async {
  await decodedData;

  return asBytes();
}