responseHeaders property
Returns all response headers as a key-value map.
Multiple values for the same header key can be combined into one, separated by a comma and a space.
See: https://xhr.spec.whatwg.org/#the-getresponseheader()-method
Implementation
Map<String, String> get responseHeaders {
// from Closure's goog.net.Xhrio.getResponseHeaders.
final headers = <String, String>{};
final headersString = getAllResponseHeaders();
final headersList =
LineSplitter.split(headersString).where((header) => header.isNotEmpty);
for (final header in headersList) {
final split = header.split(': ');
if (split.length <= 1) {
continue;
}
final key = split[0].toLowerCase();
final value = split.skip(1).join(': ');
headers.update(
key,
(oldValue) => '$oldValue, $value',
ifAbsent: () => value,
);
}
return headers;
}