recvRaw method

Future<Uint8List> recvRaw()

Next request payload; EndOfStreamError at half-close.

Implementation

Future<Uint8List> recvRaw() async {
  while (true) {
    final event = await _input.get();
    if (event == null) {
      throw StatusException(Wire.codeUnavailable, 'data channel closed');
    }
    switch (event.kind) {
      case EventKind.data:
        return event.payload!;
      case EventKind.halfClose:
        throw EndOfStreamError();
      case EventKind.trailers:
      case EventKind.rst:
        throw event.status ??
            StatusException(Wire.codeUnavailable, 'stream closed');
      default:
        break; // ignore HEADERS on the request side
    }
  }
}