toResponse method

Future<Response> toResponse(
  1. StreamedResponse streamedResponse
)
inherited

Implementation

Future<http.Response> toResponse(
    http.StreamedResponse streamedResponse) async {
  if (streamedResponse.statusCode == 204) {
    return http.Response(
      '',
      streamedResponse.statusCode,
      headers: streamedResponse.headers.map((k, v) =>
          k.toLowerCase() == 'content-type'
              ? MapEntry(k, 'text/plain')
              : MapEntry(k, v)),
      request: streamedResponse.request,
      isRedirect: streamedResponse.isRedirect,
      persistentConnection: streamedResponse.persistentConnection,
      reasonPhrase: streamedResponse.reasonPhrase,
    );
  } else {
    return await http.Response.fromStream(streamedResponse);
  }
}