Made NoDelay configurable

This commit is contained in:
Kristian Hellang 2015-12-07 22:09:04 +01:00
parent 12ee74c09c
commit 8d6a999bc3
2 changed files with 36 additions and 1 deletions

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Server.Kestrel
{ {
Addresses = GetAddresses(configuration); Addresses = GetAddresses(configuration);
ThreadCount = GetThreadCount(configuration); ThreadCount = GetThreadCount(configuration);
NoDelay = true; NoDelay = GetNoDelay(configuration);
} }
public ICollection<string> Addresses { get; } public ICollection<string> Addresses { get; }
@ -68,5 +68,23 @@ namespace Microsoft.AspNet.Server.Kestrel
return threadCount; 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;
}
} }
} }

View File

@ -62,6 +62,23 @@ namespace Microsoft.AspNet.Server.KestrelTests
Assert.Equal(expected, information.Addresses); Assert.Equal(expected, information.Addresses);
} }
[Fact]
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);
}
private static int Clamp(int value, int min, int max) private static int Clamp(int value, int min, int max)
{ {
return value < min ? min : value > max ? max : value; return value < min ? min : value > max ? max : value;