Skip to content
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

Fix throwing exception when Trailers is not available #63

Merged
merged 1 commit into from
Dec 1, 2020

Conversation

azyobuzin
Copy link
Contributor

Rin.Middlewares.RequestRecorderMiddleware sometimes outputs error logs saying:

Unhandled Exception was thrown until post-processing

System.InvalidOperationException
The request trailers are not available yet. They may not be available until the full request body is read.
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.Microsoft.AspNetCore.Http.Features.IHttpRequestTrailersFeature.get_Trailers()
   at Rin.Middlewares.RequestRecorderMiddleware.PostprocessAsync(HttpContext context, RinOptions options, HttpRequestRecord record)
   at Rin.Middlewares.RequestRecorderMiddleware.InvokeAsync(HttpContext context, RinOptions options)

This exception is thrown when IHttpRequestTrailersFeature feature is available but IHttpRequestTrailersFeature.Available is false. So checking whether that property is true is needed to read trailer.

This pull request has these changes:

  • Read Trailers property after reading the body to let the HTTP server read trailer
  • Use CheckTrailersAvailable instead of SupportsTrailers to prevent failure to read Trailers

@mayuki
Copy link
Owner

mayuki commented Dec 1, 2020

Thanks! Looks yosasou to me.

@mayuki mayuki merged commit 1771ae5 into mayuki:master Dec 1, 2020
@azyobuzin azyobuzin deleted the fix/trailers branch December 2, 2020 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants