Browse Source

Merge pull request #516 from provokateurin/fix/dynamite-response-body-speed

perf(dynamite_runtime): Increase response body reading speed
pull/522/head
Kate 1 year ago committed by GitHub
parent
commit
ef3009f286
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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