finalizeBody method

  1. @override
Future<StreamedHttpBody> finalizeBody([
  1. dynamic body
])
inherited

Finalize the request body. If a body was supplied to the request dispatch method, it will be available as body. Otherwise the body from this request should be used.

This logic is platform-specific and should be implemented by the subclass.

Implementation

@override
Future<StreamedHttpBody> finalizeBody([dynamic body]) async {
  if (body != null) {
    if (body is Stream<List<int>>) {
      this.body = body;
    } else {
      throw ArgumentError(
          'Streamed request body must be a Stream<List<int>>.');
    }
  }

  this.body ??= Stream.fromIterable([]);
  return StreamedHttpBody.fromByteStream(contentType, this.body!,
      contentLength: contentLength);
}