Browse Source

perf(dynamite_runtime): DynamiteRawResponse deserialize headers while waiting for the body

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/1161/head
Nikolas Rimikis 1 year ago
parent
commit
2cec2ed539
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 6
      packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart

6
packages/dynamite/dynamite_runtime/lib/src/dynamite_client.dart

@ -73,15 +73,15 @@ class DynamiteRawResponse<B, H> {
// ignore: discarded_futures // ignore: discarded_futures
response.then( response.then(
(final response) async { (final response) async {
_rawHeaders = response.responseHeaders;
final headers = deserializeHeaders<H>(_rawHeaders, serializers, headersType);
_rawBody = switch (bodyType) { _rawBody = switch (bodyType) {
const FullType(Uint8List) => await response.bytes, const FullType(Uint8List) => await response.bytes,
const FullType(String) => await response.string, const FullType(String) => await response.string,
_ => await response.json, _ => await response.json,
}; };
_rawHeaders = response.responseHeaders;
final body = deserializeBody<B>(_rawBody, serializers, bodyType); final body = deserializeBody<B>(_rawBody, serializers, bodyType);
final headers = deserializeHeaders<H>(_rawHeaders, serializers, headersType);
_response = DynamiteResponse<B, H>( _response = DynamiteResponse<B, H>(
response.statusCode, response.statusCode,

Loading…
Cancel
Save