scheme method

String scheme(
  1. String remote,
  2. String? forwardedProto, [
  3. String? direct
])

https when a trusted proxy says the client used https. With no word from a trusted proxy: direct, the scheme of the port (default directScheme).

Implementation

String scheme(String remote, String? forwardedProto, [String? direct]) {
  if (forwardedProto == null || !trusts(remote)) {
    return direct ?? directScheme;
  }
  String proto = forwardedProto.split(',').first.trim().toLowerCase();
  return proto == 'https' ? 'https' : 'http';
}