Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 8d6a999

Browse files
committed
Made NoDelay configurable
1 parent 12ee74c commit 8d6a999

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/Microsoft.AspNet.Server.Kestrel/KestrelServerInformation.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public KestrelServerInformation(IConfiguration configuration)
1515
{
1616
Addresses = GetAddresses(configuration);
1717
ThreadCount = GetThreadCount(configuration);
18-
NoDelay = true;
18+
NoDelay = GetNoDelay(configuration);
1919
}
2020

2121
public ICollection<string> Addresses { get; }
@@ -68,5 +68,23 @@ private static int GetThreadCount(IConfiguration configuration)
6868

6969
return threadCount;
7070
}
71+
72+
private static bool GetNoDelay(IConfiguration configuration)
73+
{
74+
var noDelayString = configuration["kestrel.noDelay"];
75+
76+
if (string.IsNullOrEmpty(noDelayString))
77+
{
78+
return true;
79+
}
80+
81+
bool noDelay;
82+
if (bool.TryParse(noDelayString, out noDelay))
83+
{
84+
return noDelay;
85+
}
86+
87+
return true;
88+
}
7189
}
7290
}

test/Microsoft.AspNet.Server.KestrelTests/KestrelServerInformationTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ public void SetAddressesUsingConfiguration()
6262
Assert.Equal(expected, information.Addresses);
6363
}
6464

65+
[Fact]
66+
public void SetNoDelayUsingConfiguration()
67+
{
68+
var values = new Dictionary<string, string>
69+
{
70+
{ "kestrel.noDelay", "false" }
71+
};
72+
73+
var configuration = new ConfigurationBuilder()
74+
.AddInMemoryCollection(values)
75+
.Build();
76+
77+
var information = new KestrelServerInformation(configuration);
78+
79+
Assert.False(information.NoDelay);
80+
}
81+
6582
private static int Clamp(int value, int min, int max)
6683
{
6784
return value < min ? min : value > max ? max : value;

0 commit comments

Comments
 (0)