Browse Source

perf(dynamite_runtime): Increase response body reading speed

pull/516/head
Nikolas Rimikis 1 year ago
parent
commit
9a0eea56ae
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 7
      packages/dynamite/dynamite_runtime/lib/src/http_client.dart

7
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<Uint8List> 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<String> get body => transform(utf8.decoder).join();

Loading…
Cancel
Save