encodedBaggage method

String? encodedBaggage()

baggage in the W3C baggage header format, or null when empty.

Keys and values are percent-encoded: an unescaped , or = would be read by the next service as a delimiter and silently split one entry into two.

Implementation

String? encodedBaggage() {
  if (baggage.isEmpty) {
    return null;
  }

  return baggage.entries
      .map(
        (e) => '${Uri.encodeQueryComponent(e.key)}='
            '${Uri.encodeQueryComponent(e.value)}',
      )
      .join(',');
}