buildCanonicalHeaders static method

String buildCanonicalHeaders(
  1. Map<String, String?> headers
)

Implementation

static String buildCanonicalHeaders(Map<String, String?> headers) {
  final sortedKeys = [];
  headers.forEach((property, _) {
    sortedKeys.add(property);
  });

  var canonicalHeaders = '';
  sortedKeys.sort((a, b) => a.toLowerCase().compareTo(b.toLowerCase()));

  for (var property in sortedKeys) {
    canonicalHeaders += '${property.toLowerCase()}:${headers[property]}\n';
  }

  return canonicalHeaders;
}