bodyBytes property

List<int> bodyBytes

Retrieves the body as a list of bytes.

The empty list is returned if there is no body.

If the handler produced a String value, the UTF-8 encoding of that value is returned.

Use bodyStr to retrieve the body as a String.

Implementation

List<int> get bodyBytes {
  if (_bodyBytes != null) {
    assert(_bodyStr == null, 'both _bodyBytes and _bodyStr are set');
    return _bodyBytes;
  } else if (_bodyStr != null) {
    return utf8.encode(_bodyStr);
  } else {
    return <int>[]; // empty list of bytes
  }
}