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

Commit f089abd

Browse files
committed
Consume in single call
1 parent f48e6ba commit f089abd

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,8 @@ public async Task RequestProcessingAsync()
232232

233233
await ProduceEnd();
234234

235-
while (await MessageBody.SkipAsync() != 0)
236-
{
237-
// Finish reading the request body in case the app did not.
238-
}
235+
// Finish reading the request body in case the app did not.
236+
await MessageBody.Consume();
239237
}
240238

241239
terminated = !_keepAlive;

src/Microsoft.AspNet.Server.Kestrel/Http/MessageBody.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,22 @@ protected MessageBody(FrameContext context)
3838
return result;
3939
}
4040

41-
public Task<int> SkipAsync(CancellationToken cancellationToken = default(CancellationToken))
41+
public async Task Consume(CancellationToken cancellationToken = default(CancellationToken))
4242
{
43-
Task<int> result = null;
44-
var send100Continue = 0;
45-
result = SkipAsyncImplementation(cancellationToken);
46-
if (!result.IsCompleted)
47-
{
48-
send100Continue = Interlocked.Exchange(ref _send100Continue, 0);
49-
}
50-
if (send100Continue == 1)
43+
Task<int> result;
44+
do
5145
{
52-
_context.FrameControl.ProduceContinue();
53-
}
54-
return result;
46+
var send100Continue = 0;
47+
result = SkipAsyncImplementation(cancellationToken);
48+
if (!result.IsCompleted)
49+
{
50+
send100Continue = Interlocked.Exchange(ref _send100Continue, 0);
51+
}
52+
if (send100Continue == 1)
53+
{
54+
_context.FrameControl.ProduceContinue();
55+
}
56+
} while (await result != 0);
5557
}
5658

5759
public abstract Task<int> ReadAsyncImplementation(ArraySegment<byte> buffer, CancellationToken cancellationToken);

0 commit comments

Comments
 (0)