Made NoDelay configurable
This commit is contained in:
parent
12ee74c09c
commit
8d6a999bc3
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Server.Kestrel
|
|||
{
|
||||
Addresses = GetAddresses(configuration);
|
||||
ThreadCount = GetThreadCount(configuration);
|
||||
NoDelay = true;
|
||||
NoDelay = GetNoDelay(configuration);
|
||||
}
|
||||
|
||||
public ICollection<string> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,23 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
|||
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)
|
||||
{
|
||||
return value < min ? min : value > max ? max : value;
|
||||
|
|
|
|||
Loading…
Reference in New Issue