Skip to content

Commit

Permalink
Still send 100 Continue with null MinRequestBodyDataRate
Browse files Browse the repository at this point in the history
  • Loading branch information
halter73 committed Apr 6, 2021
1 parent 19785cc commit 322a7b6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Servers/Kestrel/Core/src/Internal/Http/MessageBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,15 @@ protected void AddAndCheckObservedBytes(long observedBytes)

protected ValueTask<ReadResult> StartTimingReadAsync(ValueTask<ReadResult> readAwaitable, CancellationToken cancellationToken)
{

if (!readAwaitable.IsCompleted && _timingEnabled)
if (!readAwaitable.IsCompleted)
{
TryProduceContinue();

_backpressure = true;
_context.TimeoutControl.StartTimingRead();
if (_timingEnabled)
{
_backpressure = true;
_context.TimeoutControl.StartTimingRead();
}
}

return readAwaitable;
Expand Down
36 changes: 36 additions & 0 deletions src/Servers/Kestrel/test/InMemory.FunctionalTests/RequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,42 @@ await connection.ReceiveEnd(
}
}

[Fact]
public async Task Expect100ContinueHonoredWhenMinRequestBodyDataRateIsDisabled()
{
var testContext = new TestServiceContext(LoggerFactory);

// This may seem unrelated, but this is a regression test for
// https://github.com/dotnet/aspnetcore/issues/30449
testContext.ServerOptions.Limits.MinRequestBodyDataRate = null;

await using (var server = new TestServer(TestApp.EchoAppChunked, testContext))
{
using (var connection = server.CreateConnection())
{
await connection.Send(
"POST / HTTP/1.1",
"Host:",
"Expect: 100-continue",
"Connection: close",
"Content-Length: 11",
"\r\n");
await connection.Receive(
"HTTP/1.1 100 Continue",
"",
"");
await connection.Send("Hello World");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"Content-Length: 11",
"",
"Hello World");
}
}
}

[Fact]
public async Task ZeroContentLengthAssumedOnNonKeepAliveRequestsWithoutContentLengthOrTransferEncodingHeader()
{
Expand Down

0 comments on commit 322a7b6

Please sign in to comment.