normalizeHeaders static method

Map<String, String> normalizeHeaders(
  1. Map<String, dynamic> headers, {
  2. bool redact = false,
})

Normalizes a header map to Map<String, String> (values may be a List).

Implementation

static Map<String, String> normalizeHeaders(
  Map<String, dynamic> headers, {
  bool redact = false,
}) {
  final result = <String, String>{};
  headers.forEach((key, dynamic value) {
    final stringValue = value is Iterable
        ? value.map((dynamic e) => '$e').join(', ')
        : '$value';
    result[key] = redact && Redaction.isSensitive(key)
        ? Redaction.mask
        : stringValue;
  });
  return result;
}