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.
{ await MessageBody.Consume();
// Finish reading the request body in case the app did not.
}
} }
terminated = !_keepAlive; terminated = !_keepAlive;

View File

@ -38,20 +38,22 @@ 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 = null; Task<int> result;
var send100Continue = 0; do
result = SkipAsyncImplementation(cancellationToken);
if (!result.IsCompleted)
{ {
send100Continue = Interlocked.Exchange(ref _send100Continue, 0); var send100Continue = 0;
} result = SkipAsyncImplementation(cancellationToken);
if (send100Continue == 1) if (!result.IsCompleted)
{ {
_context.FrameControl.ProduceContinue(); send100Continue = Interlocked.Exchange(ref _send100Continue, 0);
} }
return result; if (send100Continue == 1)
{
_context.FrameControl.ProduceContinue();
}
} while (await result != 0);
} }
public abstract Task<int> ReadAsyncImplementation(ArraySegment<byte> buffer, CancellationToken cancellationToken); public abstract Task<int> ReadAsyncImplementation(ArraySegment<byte> buffer, CancellationToken cancellationToken);