Skip to content

Improve Http1ContentLengthMessageBody's reset logic #25799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

halter73
Copy link
Member

Addresses #19476

This prevents error logs like the following if the client closes an HTTP/1.x Content-Length request mid-body, and the last application read from the body examined data that it didn't consume:

fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HLU8P7S8VQMH", Request id "0HLU8P7S8VQMH:00000001": An unhandled exception was thrown by the application.
System.InvalidOperationException: The examined position cannot be less than the previously examined position.
   at System.IO.Pipelines.ThrowHelper.ThrowInvalidOperationException_InvalidExaminedPosition()
   at System.IO.Pipelines.Pipe.AdvanceReader(BufferSegment consumedSegment, Int32 consumedIndex, BufferSegment examinedSegment, Int32 examinedIndex)
   at System.IO.Pipelines.Pipe.DefaultPipeReader.AdvanceTo(SequencePosition consumed)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.<ReadAsyncInternal>g__ResetReadingState|9_0()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.ReadAsyncInternal(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.FormPipeReader.ReadFormAsync(CancellationToken cancellationToken)

@halter73 halter73 added this to the 5.0.0-rc2 milestone Sep 11, 2020
@ghost ghost added the area-servers label Sep 11, 2020
@halter73
Copy link
Member Author

@Pilchie for rc2

@Pilchie Pilchie added the Servicing-approved Shiproom has approved the issue label Sep 11, 2020
@Pilchie
Copy link
Member

Pilchie commented Sep 11, 2020

Approved for .NET 5 RC2

@halter73
Copy link
Member Author

@dotnet/aspnet-build Can someone please merge this? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants