|
@@ -3,14 +3,12 @@
|
|
|
|
|
|
|
|
using System;
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
-using System.Globalization;
|
|
|
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
using System.Net;
|
|
using System.Net;
|
|
|
using System.Net.Http;
|
|
using System.Net.Http;
|
|
|
using System.Text;
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
using Microsoft.AspNetCore.Http2Cat;
|
|
using Microsoft.AspNetCore.Http2Cat;
|
|
|
-using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
|
|
|
|
using Microsoft.AspNetCore.Server.IntegrationTesting.Common;
|
|
using Microsoft.AspNetCore.Server.IntegrationTesting.Common;
|
|
|
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
|
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2;
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2;
|
|
@@ -22,11 +20,13 @@ using Xunit;
|
|
|
|
|
|
|
|
namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|
namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|
|
{
|
|
{
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// These are HTTP/2 tests that work on both IIS and Express. See Http2TrailerResetTests for IIS specific tests
|
|
|
|
|
+ /// with newer functionality.
|
|
|
|
|
+ /// </summary>
|
|
|
[Collection(IISHttpsTestSiteCollection.Name)]
|
|
[Collection(IISHttpsTestSiteCollection.Name)]
|
|
|
public class Http2Tests
|
|
public class Http2Tests
|
|
|
{
|
|
{
|
|
|
- private const string WindowsVersionForTrailers = "10.0.20238";
|
|
|
|
|
-
|
|
|
|
|
public Http2Tests(IISTestSiteFixture fixture)
|
|
public Http2Tests(IISTestSiteFixture fixture)
|
|
|
{
|
|
{
|
|
|
var port = TestPortHelper.GetNextSSLPort();
|
|
var port = TestPortHelper.GetNextSSLPort();
|
|
@@ -301,31 +301,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|
|
.Build().RunAsync();
|
|
.Build().RunAsync();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task ResponseTrailers_HTTP2_TrailersAvailable()
|
|
|
|
|
- {
|
|
|
|
|
- var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_HTTP2_TrailersAvailable");
|
|
|
|
|
-
|
|
|
|
|
- response.EnsureSuccessStatusCode();
|
|
|
|
|
- Assert.Equal(HttpVersion.Version20, response.Version);
|
|
|
|
|
- Assert.Empty(response.TrailingHeaders);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
[ConditionalFact]
|
|
[ConditionalFact]
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task ResponseTrailers_ProhibitedTrailers_Blocked()
|
|
|
|
|
- {
|
|
|
|
|
- var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_ProhibitedTrailers_Blocked");
|
|
|
|
|
-
|
|
|
|
|
- response.EnsureSuccessStatusCode();
|
|
|
|
|
- Assert.Equal(HttpVersion.Version20, response.Version);
|
|
|
|
|
- Assert.Empty(response.TrailingHeaders);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
public async Task ResponseTrailers_HTTP1_TrailersNotAvailable()
|
|
public async Task ResponseTrailers_HTTP1_TrailersNotAvailable()
|
|
|
{
|
|
{
|
|
|
var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_HTTP1_TrailersNotAvailable", http2: false);
|
|
var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_HTTP1_TrailersNotAvailable", http2: false);
|
|
@@ -335,129 +311,6 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|
|
Assert.Empty(response.TrailingHeaders);
|
|
Assert.Empty(response.TrailingHeaders);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task ResponseTrailers_NoBody_TrailersSent()
|
|
|
|
|
- {
|
|
|
|
|
- var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_NoBody_TrailersSent");
|
|
|
|
|
-
|
|
|
|
|
- response.EnsureSuccessStatusCode();
|
|
|
|
|
- Assert.Equal(HttpVersion.Version20, response.Version);
|
|
|
|
|
- Assert.NotEmpty(response.TrailingHeaders);
|
|
|
|
|
- Assert.Equal("TrailerValue", response.TrailingHeaders.GetValues("TrailerName").Single());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task ResponseTrailers_WithBody_TrailersSent()
|
|
|
|
|
- {
|
|
|
|
|
- var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_WithBody_TrailersSent");
|
|
|
|
|
-
|
|
|
|
|
- response.EnsureSuccessStatusCode();
|
|
|
|
|
- Assert.Equal(HttpVersion.Version20, response.Version);
|
|
|
|
|
- Assert.Equal("Hello World", await response.Content.ReadAsStringAsync());
|
|
|
|
|
- Assert.NotEmpty(response.TrailingHeaders);
|
|
|
|
|
- Assert.Equal("Trailer Value", response.TrailingHeaders.GetValues("TrailerName").Single());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task ResponseTrailers_WithContentLengthBody_TrailersSent()
|
|
|
|
|
- {
|
|
|
|
|
- var body = "Hello World";
|
|
|
|
|
-
|
|
|
|
|
- var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_WithContentLengthBody_TrailersSent");
|
|
|
|
|
-
|
|
|
|
|
- response.EnsureSuccessStatusCode();
|
|
|
|
|
- Assert.Equal(HttpVersion.Version20, response.Version);
|
|
|
|
|
- Assert.Equal(body, await response.Content.ReadAsStringAsync());
|
|
|
|
|
- Assert.NotEmpty(response.TrailingHeaders);
|
|
|
|
|
- Assert.Equal("Trailer Value", response.TrailingHeaders.GetValues("TrailerName").Single());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task ResponseTrailers_WithTrailersBeforeContentLengthBody_TrailersSent()
|
|
|
|
|
- {
|
|
|
|
|
- var body = "Hello World";
|
|
|
|
|
-
|
|
|
|
|
- var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_WithTrailersBeforeContentLengthBody_TrailersSent");
|
|
|
|
|
-
|
|
|
|
|
- response.EnsureSuccessStatusCode();
|
|
|
|
|
- Assert.Equal(HttpVersion.Version20, response.Version);
|
|
|
|
|
- // Avoid HttpContent's automatic content-length calculation.
|
|
|
|
|
- Assert.True(response.Content.Headers.TryGetValues(HeaderNames.ContentLength, out var contentLength), HeaderNames.ContentLength);
|
|
|
|
|
- Assert.Equal((2 * body.Length).ToString(CultureInfo.InvariantCulture), contentLength.First());
|
|
|
|
|
- Assert.Equal(body + body, await response.Content.ReadAsStringAsync());
|
|
|
|
|
- Assert.NotEmpty(response.TrailingHeaders);
|
|
|
|
|
- Assert.Equal("Trailer Value", response.TrailingHeaders.GetValues("TrailerName").Single());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task ResponseTrailers_WithContentLengthBodyAndDeclared_TrailersSent()
|
|
|
|
|
- {
|
|
|
|
|
- var body = "Hello World";
|
|
|
|
|
-
|
|
|
|
|
- var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_WithContentLengthBodyAndDeclared_TrailersSent");
|
|
|
|
|
-
|
|
|
|
|
- response.EnsureSuccessStatusCode();
|
|
|
|
|
- Assert.Equal(HttpVersion.Version20, response.Version);
|
|
|
|
|
- // Avoid HttpContent's automatic content-length calculation.
|
|
|
|
|
- Assert.True(response.Content.Headers.TryGetValues(HeaderNames.ContentLength, out var contentLength), HeaderNames.ContentLength);
|
|
|
|
|
- Assert.Equal(body.Length.ToString(CultureInfo.InvariantCulture), contentLength.First());
|
|
|
|
|
- Assert.Equal("TrailerName", response.Headers.Trailer.Single());
|
|
|
|
|
- Assert.Equal(body, await response.Content.ReadAsStringAsync());
|
|
|
|
|
- Assert.NotEmpty(response.TrailingHeaders);
|
|
|
|
|
- Assert.Equal("Trailer Value", response.TrailingHeaders.GetValues("TrailerName").Single());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task ResponseTrailers_MultipleValues_SentAsSeparateHeaders()
|
|
|
|
|
- {
|
|
|
|
|
- var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_MultipleValues_SentAsSeparateHeaders");
|
|
|
|
|
-
|
|
|
|
|
- response.EnsureSuccessStatusCode();
|
|
|
|
|
- Assert.Equal(HttpVersion.Version20, response.Version);
|
|
|
|
|
- Assert.NotEmpty(response.TrailingHeaders);
|
|
|
|
|
-
|
|
|
|
|
- Assert.Equal(new[] { "TrailerValue0", "TrailerValue1" }, response.TrailingHeaders.GetValues("TrailerName"));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task ResponseTrailers_CompleteAsyncNoBody_TrailersSent()
|
|
|
|
|
- {
|
|
|
|
|
- // The app func for CompleteAsync will not finish until CompleteAsync_Completed is sent.
|
|
|
|
|
- // This verifies that the response is sent to the client with CompleteAsync
|
|
|
|
|
- var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_CompleteAsyncNoBody_TrailersSent");
|
|
|
|
|
- response.EnsureSuccessStatusCode();
|
|
|
|
|
- Assert.Equal(HttpVersion.Version20, response.Version);
|
|
|
|
|
- Assert.NotEmpty(response.TrailingHeaders);
|
|
|
|
|
- Assert.Equal("TrailerValue", response.TrailingHeaders.GetValues("TrailerName").Single());
|
|
|
|
|
-
|
|
|
|
|
- var response2 = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_CompleteAsyncNoBody_TrailersSent_Completed");
|
|
|
|
|
- Assert.True(response2.IsSuccessStatusCode);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task ResponseTrailers_CompleteAsyncWithBody_TrailersSent()
|
|
|
|
|
- {
|
|
|
|
|
- // The app func for CompleteAsync will not finish until CompleteAsync_Completed is sent.
|
|
|
|
|
- // This verifies that the response is sent to the client with CompleteAsync
|
|
|
|
|
- var response = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_CompleteAsyncWithBody_TrailersSent");
|
|
|
|
|
- response.EnsureSuccessStatusCode();
|
|
|
|
|
- Assert.Equal(HttpVersion.Version20, response.Version);
|
|
|
|
|
- Assert.Equal("Hello World", await response.Content.ReadAsStringAsync());
|
|
|
|
|
- Assert.NotEmpty(response.TrailingHeaders);
|
|
|
|
|
- Assert.Equal("Trailer Value", response.TrailingHeaders.GetValues("TrailerName").Single());
|
|
|
|
|
-
|
|
|
|
|
- var response2 = await SendRequestAsync(Fixture.Client.BaseAddress.ToString() + "ResponseTrailers_CompleteAsyncWithBody_TrailersSent_Completed");
|
|
|
|
|
- Assert.True(response2.IsSuccessStatusCode);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
[ConditionalFact]
|
|
[ConditionalFact]
|
|
|
[RequiresNewHandler]
|
|
[RequiresNewHandler]
|
|
|
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10, SkipReason = "Http2 requires Win10")]
|
|
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10, SkipReason = "Http2 requires Win10")]
|
|
@@ -485,34 +338,6 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|
|
.Build().RunAsync();
|
|
.Build().RunAsync();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [RequiresNewHandler]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task AppException_AfterHeaders_ResetInternalError()
|
|
|
|
|
- {
|
|
|
|
|
- await new HostBuilder()
|
|
|
|
|
- .UseHttp2Cat(Fixture.Client.BaseAddress.AbsoluteUri, async h2Connection =>
|
|
|
|
|
- {
|
|
|
|
|
- await h2Connection.InitializeConnectionAsync();
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Initialized http2 connection. Starting stream 1.");
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.StartStreamAsync(1, GetHeaders("/AppException_AfterHeaders_ResetInternalError"), endStream: true);
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.ReceiveHeadersAsync(1, decodedHeaders =>
|
|
|
|
|
- {
|
|
|
|
|
- Assert.Equal("200", decodedHeaders[HeaderNames.Status]);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- var frame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
-
|
|
|
|
|
- Http2Utilities.VerifyResetFrame(frame, expectedStreamId: 1, Http2ErrorCode.INTERNAL_ERROR);
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Connection stopped.");
|
|
|
|
|
- })
|
|
|
|
|
- .Build().RunAsync();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
[ConditionalFact]
|
|
[ConditionalFact]
|
|
|
[RequiresNewHandler]
|
|
[RequiresNewHandler]
|
|
|
public async Task Reset_Http1_NotSupported()
|
|
public async Task Reset_Http1_NotSupported()
|
|
@@ -528,7 +353,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|
|
[ConditionalFact]
|
|
[ConditionalFact]
|
|
|
[RequiresNewHandler]
|
|
[RequiresNewHandler]
|
|
|
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10, SkipReason = "Http2 requires Win10")]
|
|
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10, SkipReason = "Http2 requires Win10")]
|
|
|
- [MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_20H1, SkipReason = "This is last version without Reset support")]
|
|
|
|
|
|
|
+ [MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_20H2, SkipReason = "This is last version without Reset support")]
|
|
|
public async Task Reset_PriorOSVersions_NotSupported()
|
|
public async Task Reset_PriorOSVersions_NotSupported()
|
|
|
{
|
|
{
|
|
|
var handler = new HttpClientHandler();
|
|
var handler = new HttpClientHandler();
|
|
@@ -539,240 +364,6 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|
|
Assert.Equal("Hello World", response);
|
|
Assert.Equal("Hello World", response);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [RequiresNewHandler]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task Reset_BeforeResponse_Resets()
|
|
|
|
|
- {
|
|
|
|
|
- await new HostBuilder()
|
|
|
|
|
- .UseHttp2Cat(Fixture.Client.BaseAddress.AbsoluteUri, async h2Connection =>
|
|
|
|
|
- {
|
|
|
|
|
- await h2Connection.InitializeConnectionAsync();
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Initialized http2 connection. Starting stream 1.");
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.StartStreamAsync(1, GetHeaders("/Reset_BeforeResponse_Resets"), endStream: true);
|
|
|
|
|
-
|
|
|
|
|
- var resetFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Http2Utilities.VerifyResetFrame(resetFrame, expectedStreamId: 1, expectedErrorCode: (Http2ErrorCode)1111);
|
|
|
|
|
-
|
|
|
|
|
- // Any app errors?
|
|
|
|
|
- var client = CreateClient();
|
|
|
|
|
- var response = await client.GetAsync(Fixture.Client.BaseAddress + "/Reset_BeforeResponse_Resets_Complete");
|
|
|
|
|
- Assert.True(response.IsSuccessStatusCode);
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Connection stopped.");
|
|
|
|
|
- })
|
|
|
|
|
- .Build().RunAsync();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [RequiresNewHandler]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task Reset_BeforeResponse_Zero_Resets()
|
|
|
|
|
- {
|
|
|
|
|
- await new HostBuilder()
|
|
|
|
|
- .UseHttp2Cat(Fixture.Client.BaseAddress.AbsoluteUri, async h2Connection =>
|
|
|
|
|
- {
|
|
|
|
|
- await h2Connection.InitializeConnectionAsync();
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Initialized http2 connection. Starting stream 1.");
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.StartStreamAsync(1, GetHeaders("/Reset_BeforeResponse_Zero_Resets"), endStream: true);
|
|
|
|
|
-
|
|
|
|
|
- var resetFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Http2Utilities.VerifyResetFrame(resetFrame, expectedStreamId: 1, expectedErrorCode: (Http2ErrorCode)0);
|
|
|
|
|
-
|
|
|
|
|
- // Any app errors?
|
|
|
|
|
- var client = CreateClient();
|
|
|
|
|
- var response = await client.GetAsync(Fixture.Client.BaseAddress + "/Reset_BeforeResponse_Zero_Resets_Complete");
|
|
|
|
|
- Assert.True(response.IsSuccessStatusCode);
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Connection stopped.");
|
|
|
|
|
- })
|
|
|
|
|
- .Build().RunAsync();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [RequiresNewHandler]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task Reset_AfterResponseHeaders_Resets()
|
|
|
|
|
- {
|
|
|
|
|
- await new HostBuilder()
|
|
|
|
|
- .UseHttp2Cat(Fixture.Client.BaseAddress.AbsoluteUri, async h2Connection =>
|
|
|
|
|
- {
|
|
|
|
|
- await h2Connection.InitializeConnectionAsync();
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Initialized http2 connection. Starting stream 1.");
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.StartStreamAsync(1, GetHeaders("/Reset_AfterResponseHeaders_Resets"), endStream: true);
|
|
|
|
|
-
|
|
|
|
|
- // Any app errors?
|
|
|
|
|
- var client = CreateClient();
|
|
|
|
|
- var response = await client.GetAsync(Fixture.Client.BaseAddress + "/Reset_AfterResponseHeaders_Resets_Complete");
|
|
|
|
|
- Assert.True(response.IsSuccessStatusCode);
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.ReceiveHeadersAsync(1, decodedHeaders =>
|
|
|
|
|
- {
|
|
|
|
|
- Assert.Equal("200", decodedHeaders[HeaderNames.Status]);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- var resetFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Http2Utilities.VerifyResetFrame(resetFrame, expectedStreamId: 1, expectedErrorCode: (Http2ErrorCode)1111);
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Connection stopped.");
|
|
|
|
|
- })
|
|
|
|
|
- .Build().RunAsync();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [RequiresNewHandler]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task Reset_DuringResponseBody_Resets()
|
|
|
|
|
- {
|
|
|
|
|
- await new HostBuilder()
|
|
|
|
|
- .UseHttp2Cat(Fixture.Client.BaseAddress.AbsoluteUri, async h2Connection =>
|
|
|
|
|
- {
|
|
|
|
|
- await h2Connection.InitializeConnectionAsync();
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Initialized http2 connection. Starting stream 1.");
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.StartStreamAsync(1, GetHeaders("/Reset_DuringResponseBody_Resets"), endStream: true);
|
|
|
|
|
-
|
|
|
|
|
- // This is currently flaky, can either receive header or reset at this point
|
|
|
|
|
- var headerOrResetFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Assert.True(headerOrResetFrame.Type == Http2FrameType.HEADERS || headerOrResetFrame.Type == Http2FrameType.RST_STREAM);
|
|
|
|
|
-
|
|
|
|
|
- if (headerOrResetFrame.Type == Http2FrameType.HEADERS)
|
|
|
|
|
- {
|
|
|
|
|
- var dataFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Http2Utilities.VerifyDataFrame(dataFrame, 1, endOfStream: false, length: 11);
|
|
|
|
|
-
|
|
|
|
|
- var resetFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Http2Utilities.VerifyResetFrame(resetFrame, expectedStreamId: 1, expectedErrorCode: (Http2ErrorCode)1111);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- Http2Utilities.VerifyResetFrame(headerOrResetFrame, expectedStreamId: 1, expectedErrorCode: (Http2ErrorCode)1111);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Connection stopped.");
|
|
|
|
|
- })
|
|
|
|
|
- .Build().RunAsync();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [RequiresNewHandler]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task Reset_BeforeRequestBody_Resets()
|
|
|
|
|
- {
|
|
|
|
|
- await new HostBuilder()
|
|
|
|
|
- .UseHttp2Cat(Fixture.Client.BaseAddress.AbsoluteUri, async h2Connection =>
|
|
|
|
|
- {
|
|
|
|
|
- await h2Connection.InitializeConnectionAsync();
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Initialized http2 connection. Starting stream 1.");
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.StartStreamAsync(1, GetPostHeaders("/Reset_BeforeRequestBody_Resets"), endStream: false);
|
|
|
|
|
-
|
|
|
|
|
- // Any app errors?
|
|
|
|
|
- //Assert.Equal(0, await appResult.Task.DefaultTimeout());
|
|
|
|
|
-
|
|
|
|
|
- var resetFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Http2Utilities.VerifyResetFrame(resetFrame, expectedStreamId: 1, expectedErrorCode: (Http2ErrorCode)1111);
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Connection stopped.");
|
|
|
|
|
- })
|
|
|
|
|
- .Build().RunAsync();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [RequiresNewHandler]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task Reset_DuringRequestBody_Resets()
|
|
|
|
|
- {
|
|
|
|
|
- await new HostBuilder()
|
|
|
|
|
- .UseHttp2Cat(Fixture.Client.BaseAddress.AbsoluteUri, async h2Connection =>
|
|
|
|
|
- {
|
|
|
|
|
- await h2Connection.InitializeConnectionAsync();
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Initialized http2 connection. Starting stream 1.");
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.StartStreamAsync(1, GetPostHeaders("/Reset_DuringRequestBody_Resets"), endStream: false);
|
|
|
|
|
- await h2Connection.SendDataAsync(1, new byte[10], endStream: false);
|
|
|
|
|
-
|
|
|
|
|
- // Any app errors?
|
|
|
|
|
- //Assert.Equal(0, await appResult.Task.DefaultTimeout());
|
|
|
|
|
-
|
|
|
|
|
- var resetFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Http2Utilities.VerifyResetFrame(resetFrame, expectedStreamId: 1, expectedErrorCode: (Http2ErrorCode)1111);
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Connection stopped.");
|
|
|
|
|
- })
|
|
|
|
|
- .Build().RunAsync();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task Reset_AfterCompleteAsync_NoReset()
|
|
|
|
|
- {
|
|
|
|
|
- await new HostBuilder()
|
|
|
|
|
- .UseHttp2Cat(Fixture.Client.BaseAddress.AbsoluteUri, async h2Connection =>
|
|
|
|
|
- {
|
|
|
|
|
- await h2Connection.InitializeConnectionAsync();
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Initialized http2 connection. Starting stream 1.");
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.StartStreamAsync(1, GetHeaders("/Reset_AfterCompleteAsync_NoReset"), endStream: true);
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.ReceiveHeadersAsync(1, decodedHeaders =>
|
|
|
|
|
- {
|
|
|
|
|
- Assert.Equal("200", decodedHeaders[HeaderNames.Status]);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- var dataFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Http2Utilities.VerifyDataFrame(dataFrame, 1, endOfStream: false, length: 11);
|
|
|
|
|
-
|
|
|
|
|
- dataFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Http2Utilities.VerifyDataFrame(dataFrame, 1, endOfStream: true, length: 0);
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Connection stopped.");
|
|
|
|
|
- })
|
|
|
|
|
- .Build().RunAsync();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [ConditionalFact]
|
|
|
|
|
- [MinimumOSVersion(OperatingSystems.Windows, WindowsVersionForTrailers)]
|
|
|
|
|
- public async Task Reset_CompleteAsyncDuringRequestBody_Resets()
|
|
|
|
|
- {
|
|
|
|
|
- await new HostBuilder()
|
|
|
|
|
- .UseHttp2Cat(Fixture.Client.BaseAddress.AbsoluteUri, async h2Connection =>
|
|
|
|
|
- {
|
|
|
|
|
- await h2Connection.InitializeConnectionAsync();
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Initialized http2 connection. Starting stream 1.");
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.StartStreamAsync(1, GetPostHeaders("/Reset_CompleteAsyncDuringRequestBody_Resets"), endStream: false);
|
|
|
|
|
- await h2Connection.SendDataAsync(1, new byte[10], endStream: false);
|
|
|
|
|
-
|
|
|
|
|
- await h2Connection.ReceiveHeadersAsync(1, decodedHeaders =>
|
|
|
|
|
- {
|
|
|
|
|
- Assert.Equal("200", decodedHeaders[HeaderNames.Status]);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- var dataFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
-
|
|
|
|
|
- Http2Utilities.VerifyDataFrame(dataFrame, 1, endOfStream: true, length: 0);
|
|
|
|
|
-
|
|
|
|
|
- var resetFrame = await h2Connection.ReceiveFrameAsync();
|
|
|
|
|
- Http2Utilities.VerifyResetFrame(resetFrame, expectedStreamId: 1, expectedErrorCode: Http2ErrorCode.NO_ERROR);
|
|
|
|
|
-
|
|
|
|
|
- h2Connection.Logger.LogInformation("Connection stopped.");
|
|
|
|
|
- })
|
|
|
|
|
- .Build().RunAsync();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private static List<KeyValuePair<string, string>> GetHeaders(string path)
|
|
private static List<KeyValuePair<string, string>> GetHeaders(string path)
|
|
|
{
|
|
{
|
|
|
var headers = Headers.ToList();
|
|
var headers = Headers.ToList();
|
|
@@ -782,24 +373,6 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|
|
return headers;
|
|
return headers;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private static List<KeyValuePair<string, string>> GetPostHeaders(string path)
|
|
|
|
|
- {
|
|
|
|
|
- var headers = PostRequestHeaders.ToList();
|
|
|
|
|
-
|
|
|
|
|
- var kvp = new KeyValuePair<string, string>(HeaderNames.Path, path);
|
|
|
|
|
- headers.Add(kvp);
|
|
|
|
|
- return headers;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static HttpClient CreateClient()
|
|
|
|
|
- {
|
|
|
|
|
- var handler = new HttpClientHandler();
|
|
|
|
|
- handler.MaxResponseHeadersLength = 128;
|
|
|
|
|
- handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
|
|
|
|
|
- var client = new HttpClient(handler);
|
|
|
|
|
- return client;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private async Task<HttpResponseMessage> SendRequestAsync(string uri, bool http2 = true)
|
|
private async Task<HttpResponseMessage> SendRequestAsync(string uri, bool http2 = true)
|
|
|
{
|
|
{
|
|
|
var handler = new HttpClientHandler();
|
|
var handler = new HttpClientHandler();
|
|
@@ -821,12 +394,5 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|
|
new KeyValuePair<string, string>("accept-encoding", "gzip, deflate, br"),
|
|
new KeyValuePair<string, string>("accept-encoding", "gzip, deflate, br"),
|
|
|
new KeyValuePair<string, string>("upgrade-insecure-requests", "1"),
|
|
new KeyValuePair<string, string>("upgrade-insecure-requests", "1"),
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
- private static readonly IEnumerable<KeyValuePair<string, string>> PostRequestHeaders = new[]
|
|
|
|
|
- {
|
|
|
|
|
- new KeyValuePair<string, string>(HeaderNames.Method, "POST"),
|
|
|
|
|
- new KeyValuePair<string, string>(HeaderNames.Scheme, "https"),
|
|
|
|
|
- new KeyValuePair<string, string>(HeaderNames.Authority, "localhost:80"),
|
|
|
|
|
- };
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|