Skip to content

Commit 9facd9b

Browse files
authored
Still send 100 Continue with null MinRequestBodyDataRate (#31568)
1 parent dec60c8 commit 9facd9b

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

src/Servers/Kestrel/Core/src/Internal/Http/MessageBody.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,15 @@ protected void AddAndCheckObservedBytes(long observedBytes)
172172

173173
protected ValueTask<ReadResult> StartTimingReadAsync(ValueTask<ReadResult> readAwaitable, CancellationToken cancellationToken)
174174
{
175-
176-
if (!readAwaitable.IsCompleted && _timingEnabled)
175+
if (!readAwaitable.IsCompleted)
177176
{
178177
TryProduceContinue();
179178

180-
_backpressure = true;
181-
_context.TimeoutControl.StartTimingRead();
179+
if (_timingEnabled)
180+
{
181+
_backpressure = true;
182+
_context.TimeoutControl.StartTimingRead();
183+
}
182184
}
183185

184186
return readAwaitable;

src/Servers/Kestrel/test/InMemory.FunctionalTests/RequestTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,42 @@ await connection.ReceiveEnd(
846846
}
847847
}
848848

849+
[Fact]
850+
public async Task Expect100ContinueHonoredWhenMinRequestBodyDataRateIsDisabled()
851+
{
852+
var testContext = new TestServiceContext(LoggerFactory);
853+
854+
// This may seem unrelated, but this is a regression test for
855+
// https://github.com/dotnet/aspnetcore/issues/30449
856+
testContext.ServerOptions.Limits.MinRequestBodyDataRate = null;
857+
858+
await using (var server = new TestServer(TestApp.EchoAppChunked, testContext))
859+
{
860+
using (var connection = server.CreateConnection())
861+
{
862+
await connection.Send(
863+
"POST / HTTP/1.1",
864+
"Host:",
865+
"Expect: 100-continue",
866+
"Connection: close",
867+
"Content-Length: 11",
868+
"\r\n");
869+
await connection.Receive(
870+
"HTTP/1.1 100 Continue",
871+
"",
872+
"");
873+
await connection.Send("Hello World");
874+
await connection.ReceiveEnd(
875+
"HTTP/1.1 200 OK",
876+
"Connection: close",
877+
$"Date: {testContext.DateHeaderValue}",
878+
"Content-Length: 11",
879+
"",
880+
"Hello World");
881+
}
882+
}
883+
}
884+
849885
[Fact]
850886
public async Task ZeroContentLengthAssumedOnNonKeepAliveRequestsWithoutContentLengthOrTransferEncodingHeader()
851887
{

0 commit comments

Comments
 (0)