Skip to content

Commit 5e41934

Browse files
authored
Still send 100 Continue with null MinRequestBodyDataRate (#31284)
1 parent 48133cc commit 5e41934

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
@@ -154,13 +154,15 @@ protected void AddAndCheckConsumedBytes(long consumedBytes)
154154

155155
protected ValueTask<ReadResult> StartTimingReadAsync(ValueTask<ReadResult> readAwaitable, CancellationToken cancellationToken)
156156
{
157-
158-
if (!readAwaitable.IsCompleted && _timingEnabled)
157+
if (!readAwaitable.IsCompleted)
159158
{
160159
TryProduceContinue();
161160

162-
_backpressure = true;
163-
_context.TimeoutControl.StartTimingRead();
161+
if (_timingEnabled)
162+
{
163+
_backpressure = true;
164+
_context.TimeoutControl.StartTimingRead();
165+
}
164166
}
165167

166168
return readAwaitable;

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,42 @@ await connection.ReceiveEnd(
590590
}
591591
}
592592

593+
[Fact]
594+
public async Task Expect100ContinueHonoredWhenMinRequestBodyDataRateIsDisabled()
595+
{
596+
var testContext = new TestServiceContext(LoggerFactory);
597+
598+
// This may seem unrelated, but this is a regression test for
599+
// https://github.com/dotnet/aspnetcore/issues/30449
600+
testContext.ServerOptions.Limits.MinRequestBodyDataRate = null;
601+
602+
await using (var server = new TestServer(TestApp.EchoAppChunked, testContext))
603+
{
604+
using (var connection = server.CreateConnection())
605+
{
606+
await connection.Send(
607+
"POST / HTTP/1.1",
608+
"Host:",
609+
"Expect: 100-continue",
610+
"Connection: close",
611+
"Content-Length: 11",
612+
"\r\n");
613+
await connection.Receive(
614+
"HTTP/1.1 100 Continue",
615+
"",
616+
"");
617+
await connection.Send("Hello World");
618+
await connection.ReceiveEnd(
619+
"HTTP/1.1 200 OK",
620+
"Connection: close",
621+
$"Date: {testContext.DateHeaderValue}",
622+
"Content-Length: 11",
623+
"",
624+
"Hello World");
625+
}
626+
}
627+
}
628+
593629
[Fact]
594630
public async Task ZeroContentLengthAssumedOnNonKeepAliveRequestsWithoutContentLengthOrTransferEncodingHeader()
595631
{

0 commit comments

Comments
 (0)