finalizeBody method

  1. @override
Future<HttpBody> 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<HttpBody> finalizeBody([dynamic body]) async {
  if (body != null) {
    if (body is String) {
      this.body = body;
    } else if (body is List<int>) {
      bodyBytes = body;
    } else {
      throw ArgumentError(
          'Plain-text request body must be either a String or List<int>.');
    }
  }

  return HttpBody.fromBytes(contentType, bodyBytes);
}