Consume in single call

This commit is contained in:
Ben Adams 2015-11-15 21:33:31 +00:00
parent f48e6ba51a
commit f089abd337
2 changed files with 16 additions and 16 deletions

View File

@ -232,10 +232,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
await ProduceEnd(); await ProduceEnd();
while (await MessageBody.SkipAsync() != 0)
{
// Finish reading the request body in case the app did not. // Finish reading the request body in case the app did not.
} await MessageBody.Consume();
} }
terminated = !_keepAlive; terminated = !_keepAlive;

View File

@ -38,9 +38,11 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
return result; return result;
} }
public Task<int> SkipAsync(CancellationToken cancellationToken = default(CancellationToken)) public async Task Consume(CancellationToken cancellationToken = default(CancellationToken))
{
Task<int> result;
do
{ {
Task<int> result = null;
var send100Continue = 0; var send100Continue = 0;
result = SkipAsyncImplementation(cancellationToken); result = SkipAsyncImplementation(cancellationToken);
if (!result.IsCompleted) if (!result.IsCompleted)
@ -51,7 +53,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
{ {
_context.FrameControl.ProduceContinue(); _context.FrameControl.ProduceContinue();
} }
return result; } while (await result != 0);
} }
public abstract Task<int> ReadAsyncImplementation(ArraySegment<byte> buffer, CancellationToken cancellationToken); public abstract Task<int> ReadAsyncImplementation(ArraySegment<byte> buffer, CancellationToken cancellationToken);