diff --git a/src/Microsoft.AspNet.Server.Kestrel/KestrelServerInformation.cs b/src/Microsoft.AspNet.Server.Kestrel/KestrelServerInformation.cs index acbfc685e5..222a0991f3 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/KestrelServerInformation.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/KestrelServerInformation.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Server.Kestrel { Addresses = GetAddresses(configuration); ThreadCount = GetThreadCount(configuration); - NoDelay = true; + NoDelay = GetNoDelay(configuration); } public ICollection Addresses { get; } @@ -68,5 +68,23 @@ namespace Microsoft.AspNet.Server.Kestrel return threadCount; } + + private static bool GetNoDelay(IConfiguration configuration) + { + var noDelayString = configuration["kestrel.noDelay"]; + + if (string.IsNullOrEmpty(noDelayString)) + { + return true; + } + + bool noDelay; + if (bool.TryParse(noDelayString, out noDelay)) + { + return noDelay; + } + + return true; + } } } diff --git a/test/Microsoft.AspNet.Server.KestrelTests/KestrelServerInformationTests.cs b/test/Microsoft.AspNet.Server.KestrelTests/KestrelServerInformationTests.cs index 91e9a419f0..1c56258554 100644 --- a/test/Microsoft.AspNet.Server.KestrelTests/KestrelServerInformationTests.cs +++ b/test/Microsoft.AspNet.Server.KestrelTests/KestrelServerInformationTests.cs @@ -62,6 +62,23 @@ namespace Microsoft.AspNet.Server.KestrelTests Assert.Equal(expected, information.Addresses); } + [Fact] + public void SetNoDelayUsingConfiguration() + { + var values = new Dictionary + { + { "kestrel.noDelay", "false" } + }; + + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(values) + .Build(); + + var information = new KestrelServerInformation(configuration); + + Assert.False(information.NoDelay); + } + private static int Clamp(int value, int min, int max) { return value < min ? min : value > max ? max : value;