<commit_before>﻿using System;
using System.IO;

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Net.Http.Server;

namespace FubarDev.WebDavServer.Sample.AspNetCore
{
    public class Program
    {
        public static bool IsKestrel { get; private set; }

        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                .SetBasePath(AppContext.BaseDirectory)
                .AddJsonFile("hosting.json", true)
                .AddCommandLine(args)
                .Build();

            var forceKestrelUse = config.GetValue<bool>("use-kestrel");

            IWebHost host;
            if (!forceKestrelUse && IsWindows())
            {
                host = new WebHostBuilder()
                    .UseWebListener(opt =>
                    {
                        opt.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.NTLM;
                        opt.ListenerSettings.Authentication.AllowAnonymous = true;
                    })
                    .UseConfiguration(config)
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseStartup<Startup>()
                    .Build();
            }
            else
            {
                IsKestrel = true;
                host = new WebHostBuilder()
                    .UseKestrel()
                    .UseConfiguration(config)
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseIISIntegration()
                    .UseStartup<Startup>()
                    .Build();
            }

            host.Run();
        }

        public static bool IsWindows()
        {
            string windir = Environment.GetEnvironmentVariable("windir");
            return !string.IsNullOrEmpty(windir) && windir.Contains(@"\") && Directory.Exists(windir);
        }
    }
}<commit_msg>New command line argument "--use-pfx" to enable HTTPS<commit_after>﻿using System;
using System.IO;

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Net.Http.Server;

namespace FubarDev.WebDavServer.Sample.AspNetCore
{
    public class Program
    {
        public static bool IsKestrel { get; private set; }

        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                .SetBasePath(AppContext.BaseDirectory)
                .AddJsonFile("hosting.json", true)
                .AddCommandLine(args)
                .Build();

            var forceKestrelUse = config.GetValue<bool>("use-kestrel");

            IWebHost host;
            if (!forceKestrelUse && IsWindows)
            {
                host = new WebHostBuilder()
                    .UseWebListener(opt =>
                    {
                        opt.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.NTLM;
                        opt.ListenerSettings.Authentication.AllowAnonymous = true;
                    })
                    .UseConfiguration(config)
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseStartup<Startup>()
                    .Build();
            }
            else
            {
                var pfxFileName = config.GetValue<string>("use-pfx");
                IsKestrel = true;
                host = new WebHostBuilder()
                    .UseKestrel(
                        opt =>
                        {
                            if (!string.IsNullOrEmpty(pfxFileName))
                            {
                                opt.UseHttps(pfxFileName);
                            }
                        })
                    .UseConfiguration(config)
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseIISIntegration()
                    .UseStartup<Startup>()
                    .Build();
            }

            host.Run();
        }

        public static bool IsWindows
        {
            get
            {
                string windir = Environment.GetEnvironmentVariable("windir");
                return !string.IsNullOrEmpty(windir) && windir.Contains(@"\") && Directory.Exists(windir);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08991635687732343, 'fraction_numerical': 0.0, 'mean_word_length': 1.3132724341751747, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7551929', 'n_tokens_mistral': 1045, 'n_tokens_neox': 990, 'n_words': 175}