diff --git a/packages/dynamite/dynamite_runtime/lib/src/http_client.dart b/packages/dynamite/dynamite_runtime/lib/src/http_client.dart index b1b5c9b1..53141502 100644 --- a/packages/dynamite/dynamite_runtime/lib/src/http_client.dart +++ b/packages/dynamite/dynamite_runtime/lib/src/http_client.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'dart:typed_data'; @@ -8,9 +9,11 @@ export 'package:cookie_jar/cookie_jar.dart'; extension DynamiteHttpClientResponseBody on HttpClientResponse { Future get bodyBytes async { - final data = await expand((final element) => element).toList(); + final buffer = BytesBuilder(); - return Uint8List.fromList(data); + await forEach(buffer.add); + + return buffer.toBytes(); } Future get body => transform(utf8.decoder).join();