header method

String header(
  1. Uri uri
)

Implementation

String header(Uri uri) {
  _cookies.removeWhere((key, value) =>
      value.expires != null && !value.expires!.isAfter(_clock()));
  final matching = _cookies.values
      .where((value) =>
          value.host == uri.host &&
          (!value.cookie.secure || uri.scheme == 'https') &&
          (uri.path == value.path ||
              uri.path.startsWith(
                  value.path.endsWith('/') ? value.path : '${value.path}/')))
      .toList()
    ..sort((a, b) => b.path.length.compareTo(a.path.length));
  return matching
      .map((value) => '${value.cookie.name}=${value.cookie.value}')
      .join('; ');
}