https://dev.azure.com/dnceng/public/_build/results?buildId=1047582&view=ms.vss-test-web.build-test-results-tab&runId=32399144&resultId=107690&paneView=dotnet-dnceng.dnceng-build-release-tasks.helix-test-information-tab
[0.001s] [TestLifetime] [Information] Starting test RequestTrailers_CanReadTrailersFromRequest at 2021-03-19T15:34:51
[0.027s] [Microsoft.AspNetCore.Server.Kestrel] [Debug] Connection id "null", Request id "null": started reading request body.
[0.030s] [Microsoft.AspNetCore.Server.Kestrel] [Error] Connection id "null", Request id "null": An unhandled exception was thrown by the application.
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() in /_/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.FeatureCollection.cs:line 136
at Microsoft.AspNetCore.Http.RequestTrailerExtensions.GetTrailer(HttpRequest request, String trailerName) in /_/src/Http/Http.Abstractions/src/Extensions/RequestTrailerExtensions.cs:line 59
at Microsoft.AspNetCore.Server.Kestrel.Core.Tests.Http3StreamTests.<>c__DisplayClass47_0.<<RequestTrailers_CanReadTrailersFromRequest>b__0>d.MoveNext() in /_/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3StreamTests.cs:line 1657
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Testing.DummyApplication.ProcessRequestAsync(HttpContext context) in /_/src/Servers/Kestrel/shared/test/DummyApplication.cs:line 45
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application) in /_/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.cs:line 663
[0.030s] [Microsoft.AspNetCore.Server.Kestrel] [Verbose] Connection id "null" sending HEADERS frame for stream ID 0 with length 57.
[0.030s] [Microsoft.AspNetCore.Server.Kestrel] [Debug] Connection id "null", Request id "null": done reading request body.
[0.172s] [Microsoft.AspNetCore.Server.Kestrel.Core.Tests.Http3StreamTests] [Error] Test threw an exception.
Xunit.Sdk.EqualException: Assert.Equal() Failure
Expected: TestValue
Actual: (null)
at Xunit.Assert.Equal(String expected, String actual, Boolean ignoreCase, Boolean ignoreLineEndingDifferences, Boolean ignoreWhiteSpaceDifferences) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\StringAsserts.cs:line 244
at Xunit.Assert.Equal(String expected, String actual) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\StringAsserts.cs:line 174
at Microsoft.AspNetCore.Server.Kestrel.Core.Tests.Http3StreamTests.RequestTrailers_CanReadTrailersFromRequest() in /_/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3StreamTests.cs:line 1666
at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 264
--- End of stack trace from previous location ---
at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 48
at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 90
[0.182s] [TestLifetime] [Information] Finished test RequestTrailers_CanReadTrailersFromRequest in 0.1818112s
|
var requestStream = await InitializeConnectionAndStreamsAsync(async c => |
|
{ |
|
var data = new byte[1024]; |
|
await c.Request.Body.ReadAsync(data); |
|
|
|
testValue = c.Request.GetTrailer("TestName"); |
|
}); |
|
|
|
await requestStream.SendHeadersAsync(headers, endStream: false); |
|
await requestStream.SendDataAsync(Encoding.UTF8.GetBytes("Hello world")); |
|
await requestStream.SendHeadersAsync(trailers, endStream: true); |
This code is racy, it assumes that just because one read completed, that the trailers will be available. It needs to read until read returns 0 before checking for trailers.
cc: @JamesNK
https://dev.azure.com/dnceng/public/_build/results?buildId=1047582&view=ms.vss-test-web.build-test-results-tab&runId=32399144&resultId=107690&paneView=dotnet-dnceng.dnceng-build-release-tasks.helix-test-information-tab
aspnetcore/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3StreamTests.cs
Lines 1652 to 1662 in 4f3e8e0
This code is racy, it assumes that just because one read completed, that the trailers will be available. It needs to read until read returns 0 before checking for trailers.
cc: @JamesNK