-
Notifications
You must be signed in to change notification settings - Fork 10.5k
HTTP/3 with IIS #35934
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
HTTP/3 with IIS #35934
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f3f8a12
Add failing test
wtgodbe b8c8735
Another bad test
wtgodbe ce36dd3
Weird tests
wtgodbe 2dd8648
Add IIS tests for HTTP/3
wtgodbe 0be6a68
Undo changes
wtgodbe 0beb1e2
Fixup
wtgodbe acc1734
Move attribute
wtgodbe e13a375
Feedback
wtgodbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <Project> | ||
| <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" /> | ||
| <PropertyGroup> | ||
| <KestrelSharedSourceRoot>$(MSBuildThisFileDirectory)..\Kestrel\shared\</KestrelSharedSourceRoot> | ||
| </PropertyGroup> | ||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
178 changes: 178 additions & 0 deletions
178
src/Servers/IIS/IIS/test/IIS.FunctionalTests/Http3Tests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.Linq; | ||
| using System.Net; | ||
| using System.Net.Http; | ||
| using System.Net.Quic; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Server.IIS.FunctionalTests; | ||
| using Microsoft.AspNetCore.Server.IntegrationTesting.Common; | ||
| using Microsoft.AspNetCore.Server.IntegrationTesting.IIS; | ||
| using Microsoft.AspNetCore.Testing; | ||
| using Microsoft.Extensions.Hosting; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Net.Http.Headers; | ||
| using Microsoft.Win32; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests | ||
| { | ||
| [MsQuicSupported] | ||
| [HttpSysHttp3Supported] | ||
| [Collection(IISHttpsTestSiteCollection.Name)] | ||
| public class Http3Tests | ||
| { | ||
| public Http3Tests(IISTestSiteFixture fixture) | ||
| { | ||
| var port = TestPortHelper.GetNextSSLPort(); | ||
| fixture.DeploymentParameters.ApplicationBaseUriHint = $"https://localhost:{port}/"; | ||
| fixture.DeploymentParameters.AddHttpsToServerConfig(); | ||
| fixture.DeploymentParameters.SetWindowsAuth(false); | ||
| Fixture = fixture; | ||
| } | ||
|
|
||
| public IISTestSiteFixture Fixture { get; } | ||
|
|
||
| [ConditionalFact] | ||
| public async Task Http3_Direct() | ||
| { | ||
| using var client = SetUpClient(); | ||
| client.DefaultRequestVersion = HttpVersion.Version30; | ||
| client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact; | ||
| var response = await client.GetAsync(Fixture.Client.BaseAddress.ToString() + "Http3_Direct"); | ||
|
|
||
| response.EnsureSuccessStatusCode(); | ||
| Assert.Equal(HttpVersion.Version30, response.Version); | ||
| Assert.Equal("HTTP/3", await response.Content.ReadAsStringAsync()); | ||
| } | ||
|
|
||
| [ConditionalFact] | ||
| public async Task Http3_AltSvcHeader_UpgradeFromHttp1() | ||
| { | ||
| var address = Fixture.Client.BaseAddress.ToString() + "Http3_AltSvcHeader_UpgradeFromHttp1"; | ||
|
|
||
| var altsvc = $@"h3="":{new Uri(address).Port}"""; | ||
| using var client = SetUpClient(); | ||
| client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher; | ||
|
|
||
| // First request is HTTP/1.1, gets an alt-svc response | ||
| var request = new HttpRequestMessage(HttpMethod.Get, address); | ||
| request.Version = HttpVersion.Version11; | ||
| request.VersionPolicy = HttpVersionPolicy.RequestVersionExact; | ||
| var response1 = await client.SendAsync(request); | ||
| response1.EnsureSuccessStatusCode(); | ||
| Assert.Equal("HTTP/1.1", await response1.Content.ReadAsStringAsync()); | ||
| Assert.Equal(altsvc, response1.Headers.GetValues(HeaderNames.AltSvc).SingleOrDefault()); | ||
|
|
||
| // Second request is HTTP/3 | ||
| var response3 = await client.GetAsync(address); | ||
| Assert.Equal(HttpVersion.Version30, response3.Version); | ||
| Assert.Equal("HTTP/3", await response3.Content.ReadAsStringAsync()); | ||
| } | ||
|
|
||
| [ConditionalFact] | ||
| public async Task Http3_AltSvcHeader_UpgradeFromHttp2() | ||
| { | ||
| var address = Fixture.Client.BaseAddress.ToString() + "Http3_AltSvcHeader_UpgradeFromHttp2"; | ||
|
|
||
| var altsvc = $@"h3="":{new Uri(address).Port}"""; | ||
| using var client = SetUpClient(); | ||
| client.DefaultRequestVersion = HttpVersion.Version20; | ||
| client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher; | ||
|
|
||
| // First request is HTTP/2, gets an alt-svc response | ||
| var response2 = await client.GetAsync(address); | ||
| response2.EnsureSuccessStatusCode(); | ||
| Assert.Equal(altsvc, response2.Headers.GetValues(HeaderNames.AltSvc).SingleOrDefault()); | ||
| Assert.Equal("HTTP/2", await response2.Content.ReadAsStringAsync()); | ||
|
|
||
| // Second request is HTTP/3 | ||
| var response3 = await client.GetStringAsync(address); | ||
| Assert.Equal("HTTP/3", response3); | ||
| } | ||
|
|
||
| [ConditionalFact] | ||
| public async Task Http3_ResponseTrailers() | ||
| { | ||
| var address = Fixture.Client.BaseAddress.ToString() + "Http3_ResponseTrailers"; | ||
| using var client = SetUpClient(); | ||
| client.DefaultRequestVersion = HttpVersion.Version30; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: consider passing these in to SetupClient to further streamline the tests |
||
| client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact; | ||
| var response = await client.GetAsync(address); | ||
| response.EnsureSuccessStatusCode(); | ||
| var result = await response.Content.ReadAsStringAsync(); | ||
| Assert.Equal("HTTP/3", result); | ||
| Assert.Equal("value", response.TrailingHeaders.GetValues("custom").SingleOrDefault()); | ||
| } | ||
|
|
||
| [ConditionalFact] | ||
| public async Task Http3_ResetBeforeHeaders() | ||
| { | ||
| var address = Fixture.Client.BaseAddress.ToString() + "Http3_ResetBeforeHeaders"; | ||
| using var client = SetUpClient(); | ||
| client.DefaultRequestVersion = HttpVersion.Version30; | ||
| client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact; | ||
| var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(address)); | ||
| var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException); | ||
| Assert.Equal(0x010b, qex.ErrorCode); | ||
| } | ||
|
|
||
| [ConditionalFact] | ||
| public async Task Http3_ResetAfterHeaders() | ||
| { | ||
| var address = Fixture.Client.BaseAddress.ToString() + "Http3_ResetAfterHeaders"; | ||
| using var client = SetUpClient(); | ||
| client.DefaultRequestVersion = HttpVersion.Version30; | ||
| client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact; | ||
| var response = await client.GetAsync(address, HttpCompletionOption.ResponseHeadersRead); | ||
| await client.GetAsync(Fixture.Client.BaseAddress.ToString() + "Http3_ResetAfterHeaders_SetResult"); | ||
| response.EnsureSuccessStatusCode(); | ||
| var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync()); | ||
| var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException?.InnerException?.InnerException); | ||
| Assert.Equal(0x010c, qex.ErrorCode); // H3_REQUEST_CANCELLED | ||
| } | ||
|
|
||
| [ConditionalFact] | ||
| public async Task Http3_AppExceptionAfterHeaders_InternalError() | ||
| { | ||
| var address = Fixture.Client.BaseAddress.ToString() + "Http3_AppExceptionAfterHeaders_InternalError"; | ||
| using var client = SetUpClient(); | ||
| client.DefaultRequestVersion = HttpVersion.Version30; | ||
| client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact; | ||
|
|
||
| var response = await client.GetAsync(address, HttpCompletionOption.ResponseHeadersRead); | ||
| await client.GetAsync(Fixture.Client.BaseAddress.ToString() + "Http3_AppExceptionAfterHeaders_InternalError_SetResult"); | ||
| response.EnsureSuccessStatusCode(); | ||
| var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync()); | ||
| var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException?.InnerException?.InnerException); | ||
| Assert.Equal(0x0102, qex.ErrorCode); // H3_INTERNAL_ERROR | ||
wtgodbe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| [ConditionalFact] | ||
| public async Task Http3_Abort_Cancel() | ||
| { | ||
| var address = Fixture.Client.BaseAddress.ToString() + "Http3_Abort_Cancel"; | ||
| using var client = SetUpClient(); | ||
| client.DefaultRequestVersion = HttpVersion.Version30; | ||
| client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact; | ||
|
|
||
| var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(address)); | ||
| var qex = Assert.IsType<QuicStreamAbortedException>(ex.InnerException); | ||
| Assert.Equal(0x010c, qex.ErrorCode); // H3_REQUEST_CANCELLED | ||
| } | ||
|
|
||
| private HttpClient SetUpClient() | ||
| { | ||
| var handler = new HttpClientHandler(); | ||
| // Needed on CI, the IIS Express cert we use isn't trusted there. | ||
| handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; | ||
| return new HttpClient(handler); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider moving this to https://github.com/dotnet/aspnetcore/tree/main/src/Shared/Kestrel or something? Is there a reason it needs to be special?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's grown very organically, it used to only be shared within Kestrel projects, now it's shared across all the servers. It might be worth moving, but not in this PR. Will, file an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#36035