Commit aff752f8 authored by Chinmay Garde's avatar Chinmay Garde

mojo_client: Dont try to iterate over response headers if there aren't any. (#3811)

parent 8e9334fc
...@@ -180,11 +180,13 @@ class MojoClient { ...@@ -180,11 +180,13 @@ class MojoClient {
ByteData data = await mojo.DataPipeDrainer.drainHandle(response.body); ByteData data = await mojo.DataPipeDrainer.drainHandle(response.body);
Uint8List bodyBytes = new Uint8List.view(data.buffer); Uint8List bodyBytes = new Uint8List.view(data.buffer);
Map<String, String> headers = <String, String>{}; Map<String, String> headers = <String, String>{};
if (response.headers != null) {
for (mojom.HttpHeader header in response.headers) { for (mojom.HttpHeader header in response.headers) {
String headerName = header.name.toLowerCase(); String headerName = header.name.toLowerCase();
String existingValue = headers[headerName]; String existingValue = headers[headerName];
headers[headerName] = existingValue != null ? '$existingValue, ${header.value}' : header.value; headers[headerName] = existingValue != null ? '$existingValue, ${header.value}' : header.value;
} }
}
return new Response.bytes(bodyBytes, response.statusCode, headers: headers); return new Response.bytes(bodyBytes, response.statusCode, headers: headers);
} catch (exception, stack) { } catch (exception, stack) {
FlutterError.reportError(new FlutterErrorDetails( FlutterError.reportError(new FlutterErrorDetails(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment