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,10 +180,12 @@ class MojoClient {
ByteData data = await mojo.DataPipeDrainer.drainHandle(response.body);
Uint8List bodyBytes = new Uint8List.view(data.buffer);
Map<String, String> headers = <String, String>{};
for (mojom.HttpHeader header in response.headers) {
String headerName = header.name.toLowerCase();
String existingValue = headers[headerName];
headers[headerName] = existingValue != null ? '$existingValue, ${header.value}' : header.value;
if (response.headers != null) {
for (mojom.HttpHeader header in response.headers) {
String headerName = header.name.toLowerCase();
String existingValue = headers[headerName];
headers[headerName] = existingValue != null ? '$existingValue, ${header.value}' : header.value;
}
}
return new Response.bytes(bodyBytes, response.statusCode, headers: headers);
} catch (exception, stack) {
......
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