public IServer CreateServer(IConfiguration configuration) { var information = new KestrelServerInformation(configuration); var serverFeatures = new FeatureCollection(); serverFeatures.Set<IKestrelServerInformation>(information); serverFeatures.Set<IServerAddressesFeature>(information); return new KestrelServer(serverFeatures, _appLifetime, _loggerFactory.CreateLogger("Microsoft.AspNet.Server.Kestrel")); }
public IServer CreateServer(IConfiguration configuration) { var information = new KestrelServerInformation(configuration); var serverFeatures = new FeatureCollection(); serverFeatures.Set <IKestrelServerInformation>(information); serverFeatures.Set <IServerAddressesFeature>(information); return(new KestrelServer(serverFeatures, _appLifetime, _loggerFactory.CreateLogger("Microsoft.AspNet.Server.Kestrel"))); }
public IFeatureCollection Initialize(IConfiguration configuration) { var information = new KestrelServerInformation(); information.Initialize(configuration); var serverFeatures = new FeatureCollection(); serverFeatures.Set<IKestrelServerInformation>(information); serverFeatures.Set<IServerAddressesFeature>(information); return serverFeatures; }
public IFeatureCollection Initialize(IConfiguration configuration) { var information = new KestrelServerInformation(); information.Initialize(configuration); var serverFeatures = new FeatureCollection(); serverFeatures.Set <IKestrelServerInformation>(information); serverFeatures.Set <IServerAddressesFeature>(information); return(serverFeatures); }
public void SetThreadCountUsingProcessorCount() { // Ideally we'd mock Environment.ProcessorCount to test edge cases. var expected = Clamp(Environment.ProcessorCount >> 1, 1, 16); var configuration = new ConfigurationBuilder().Build(); var information = new KestrelServerInformation(configuration); Assert.Equal(expected, information.ThreadCount); }
public void StartWithEmptyAddressesThrows() { var server = CreateServer(configuration => { var information = new KestrelServerInformation(configuration); information.Addresses.Clear(); return information; }); var exception = Assert.Throws<InvalidOperationException>(() => StartDummyApplication(server)); Assert.Equal("No recognized listening addresses were configured.", exception.Message); }
public void SetNoDelayUsingConfiguration() { var values = new Dictionary<string, string> { { "kestrel.noDelay", "false" } }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(values) .Build(); var information = new KestrelServerInformation(configuration); Assert.False(information.NoDelay); }
public void SetAddressesUsingConfiguration() { var expected = new List<string> { "http://localhost:1337", "https://localhost:42" }; var values = new Dictionary<string, string> { { "server.urls", string.Join(";", expected) } }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(values) .Build(); var information = new KestrelServerInformation(configuration); Assert.Equal(expected, information.Addresses); }
public void SetThreadCountUsingConfiguration() { const int expected = 42; var values = new Dictionary<string, string> { { "kestrel.threadCount", expected.ToString() } }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(values) .Build(); var information = new KestrelServerInformation(configuration); Assert.Equal(expected, information.ThreadCount); }
public void SetReuseStreamsUsingConfiguration(string input, bool expected) { var values = new Dictionary<string, string> { { "kestrel.reuseStreams", input } }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(values) .Build(); var information = new KestrelServerInformation(configuration); Assert.Equal(expected, information.ReuseStreams); }