private SemaphoreSlim? _http2ConnectionCreateLock;
private byte[]? _http2AltSvcOriginUri;
internal readonly byte[]? _http2EncodedAuthorityHostHeader;
-
- [SupportedOSPlatformGuard("linux")]
- [SupportedOSPlatformGuard("macOS")]
- [SupportedOSPlatformGuard("Windows")]
private readonly bool _http3Enabled;
private Http3Connection? _http3Connection;
private SemaphoreSlim? _http3ConnectionCreateLock;
[SupportedOSPlatformGuard("macOS")]
[SupportedOSPlatformGuard("Windows")]
internal static bool IsHttp3Supported() => (OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS();
+
private static readonly List<SslApplicationProtocol> s_http3ApplicationProtocols = CreateHttp3ApplicationProtocols();
private static readonly List<SslApplicationProtocol> s_http2ApplicationProtocols = new List<SslApplicationProtocol>() { SslApplicationProtocol.Http2, SslApplicationProtocol.Http11 };
private static readonly List<SslApplicationProtocol> s_http2OnlyApplicationProtocols = new List<SslApplicationProtocol>() { SslApplicationProtocol.Http2 };
/// <summary>
/// HTTP/3 tests by default use prenegotiated HTTP/3. To test Alt-Svc upgrades, that must be disabled.
/// </summary>
- protected override HttpClient CreateHttpClient()
+ private HttpClient CreateHttpClient(Version version)
{
- HttpClientHandler handler = CreateHttpClientHandler(HttpVersion.Version30);
-
- return CreateHttpClient(handler);
+ var client = CreateHttpClient();
+ client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher;
+ client.DefaultRequestVersion = version;
+ return client;
}
[Theory]
// The second request is expected to come in on this HTTP/3 server.
using Http3LoopbackServer secondServer = CreateHttp3LoopbackServer();
- using HttpClient client = CreateHttpClient();
+ using HttpClient client = CreateHttpClient(fromVersion);
Task<HttpResponseMessage> firstResponseTask = client.GetAsync(firstServer.Address);
Task serverTask = firstServer.AcceptConnectionSendResponseAndCloseAsync(additionalHeaders: new[]
{
using Http2LoopbackServer firstServer = Http2LoopbackServer.CreateServer();
using Http3LoopbackServer secondServer = CreateHttp3LoopbackServer();
- using HttpClient client = CreateHttpClient();
+ using HttpClient client = CreateHttpClient(HttpVersion.Version20);
Task<HttpResponseMessage> firstResponseTask = client.GetAsync(firstServer.Address);
Task serverTask = Task.Run(async () =>
{
using Http2LoopbackServer firstServer = Http2LoopbackServer.CreateServer();
using Http3LoopbackServer secondServer = CreateHttp3LoopbackServer();
- using HttpClient client = CreateHttpClient();
+ using HttpClient client = CreateHttpClient(HttpVersion.Version20);
Task<HttpResponseMessage> firstResponseTask = client.GetAsync(firstServer.Address);
Task serverTask = Task.Run(async () =>
protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.Mock;
}
- // TODO: Many AltSvc tests are failing for HTTP3.
- [ActiveIssue("https://github.com/dotnet/runtime/issues/53093")]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
public sealed class SocketsHttpHandler_HttpClientHandler_AltSvc_Test_Http3_MsQuic : HttpClientHandler_AltSvc_Test
{
protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.MsQuic;
}
- [ActiveIssue("https://github.com/dotnet/runtime/issues/53093")]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
public sealed class SocketsHttpHandler_HttpClientHandler_AltSvc_Test_Http3_Mock : HttpClientHandler_AltSvc_Test
{