mojo_client: Dont try to iterate over response headers if there aren't any. (#3811)
This commit is contained in:
parent
8e9334fc32
commit
aff752f802
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user