cockpit_connection_get_protocol (GIOStream *connection,
                                 GHashTable *headers,
                                 gboolean for_tls_proxy)
{
  const gchar *protocol = NULL;
  const gchar *protocol_header;

  if (connection && G_IS_TLS_CONNECTION (connection))
    {
      protocol = "https";
    }
  else
    {
      protocol_header = cockpit_conf_string ("WebService", "ProtocolHeader");
      if (protocol_header && headers)
         protocol = g_hash_table_lookup (headers, protocol_header);
    }

  return protocol ?: (for_tls_proxy ? "https" : "http");
}
cockpit_connection_get_protocol (GIOStream *connection,
                                 GHashTable *headers,
                                 gboolean for_tls_proxy)
{
  const gchar *protocol = NULL;
  const gchar *protocol_header;

  if (connection && G_IS_TLS_CONNECTION (connection))
    {
      protocol = "https";
    }
  else
    {
      protocol_header = cockpit_conf_string ("WebService", "ProtocolHeader");
      if (protocol_header && headers)
         protocol = g_hash_table_lookup (headers, protocol_header);
    }

  return protocol ?: (for_tls_proxy ? "https" : "http");
}