Call Complete on Http2Stream when stream is done earlier (#7933)
This commit is contained in:
parent
a2c8a34556
commit
bbe4a9d071
|
|
@ -368,11 +368,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
|
|||
{
|
||||
RequestBodyPipe.Writer.Write(segment.Span);
|
||||
}
|
||||
var flushTask = RequestBodyPipe.Writer.FlushAsync();
|
||||
|
||||
// It shouldn't be possible for the RequestBodyPipe to fill up an return an incomplete task if
|
||||
// _inputFlowControl.Advance() didn't throw.
|
||||
Debug.Assert(flushTask.IsCompleted);
|
||||
// If the stream is completed go ahead and call RequestBodyPipe.Writer.Complete().
|
||||
// Data will still be available to the reader.
|
||||
if (!endStream)
|
||||
{
|
||||
var flushTask = RequestBodyPipe.Writer.FlushAsync();
|
||||
// It shouldn't be possible for the RequestBodyPipe to fill up an return an incomplete task if
|
||||
// _inputFlowControl.Advance() didn't throw.
|
||||
Debug.Assert(flushTask.IsCompleted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1023,8 +1023,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
await InitializeConnectionAsync(async context =>
|
||||
{
|
||||
var readResult = await context.Request.BodyPipe.ReadAsync();
|
||||
Assert.Equal(12, readResult.Buffer.Length);
|
||||
Assert.True(readResult.IsCompleted);
|
||||
Assert.Equal(12, readResult.Buffer.Length);
|
||||
context.Request.BodyPipe.AdvanceTo(readResult.Buffer.End);
|
||||
|
||||
readResult = await context.Request.BodyPipe.ReadAsync();
|
||||
|
|
|
|||
Loading…
Reference in New Issue