From 40ed818e5ecd9f413ca75bb62c2eb4913acbc723 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marie=20P=C3=ADchov=C3=A1?= <11718369+ManickaP@users.noreply.github.com> Date: Fri, 6 Aug 2021 09:35:12 +0200 Subject: [PATCH] [HTTP/3] Reenable interop tests (#56867) * Reenabled tests * Fixed interop tests, fixed handling of 0-byte DATA frame * Addressed comments --- .../Http/SocketsHttpHandler/Http3RequestStream.cs | 5 ++ .../FunctionalTests/HttpClientHandlerTest.Http3.cs | 55 ++++++++++++++++++---- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs index cd530ae..bd359c3 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs @@ -1156,6 +1156,11 @@ namespace System.Net.Http switch (frameType) { case Http3FrameType.Data: + // Ignore DATA frames with 0 length. + if (payloadLength == 0) + { + continue; + } _responseDataPayloadRemaining = payloadLength; return true; case Http3FrameType.Headers: diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http3.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http3.cs index fd18490..0e1274d 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http3.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http3.cs @@ -416,7 +416,6 @@ namespace System.Net.Http.Functional.Tests [OuterLoop] [ConditionalTheory(nameof(IsMsQuicSupported))] [MemberData(nameof(InteropUris))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/54726")] public async Task Public_Interop_ExactVersion_Success(string uri) { if (UseQuicImplementationProvider == QuicImplementationProviders.Mock) @@ -440,8 +439,34 @@ namespace System.Net.Http.Functional.Tests [OuterLoop] [ConditionalTheory(nameof(IsMsQuicSupported))] + [MemberData(nameof(InteropUrisWithContent))] + public async Task Public_Interop_ExactVersion_BufferContent_Success(string uri) + { + if (UseQuicImplementationProvider == QuicImplementationProviders.Mock) + { + return; + } + + using HttpClient client = CreateHttpClient(); + using HttpRequestMessage request = new HttpRequestMessage + { + Method = HttpMethod.Get, + RequestUri = new Uri(uri, UriKind.Absolute), + Version = HttpVersion.Version30, + VersionPolicy = HttpVersionPolicy.RequestVersionExact + }; + using HttpResponseMessage response = await client.SendAsync(request, HttpCompletionOption.ResponseContentRead).WaitAsync(TimeSpan.FromSeconds(20)); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal(3, response.Version.Major); + + var content = await response.Content.ReadAsStringAsync(); + Assert.NotEmpty(content); + } + + [OuterLoop] + [ConditionalTheory(nameof(IsMsQuicSupported))] [MemberData(nameof(InteropUris))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/54726")] public async Task Public_Interop_Upgrade_Success(string uri) { if (UseQuicImplementationProvider == QuicImplementationProviders.Mock) @@ -449,7 +474,9 @@ namespace System.Net.Http.Functional.Tests return; } - using HttpClient client = CreateHttpClient(); + // Create the handler manually without passing in useVersion = Http3 to avoid using VersionHttpClientHandler, + // because it overrides VersionPolicy on each request with RequestVersionExact (bypassing Alt-Svc code path completely). + using HttpClient client = CreateHttpClient(CreateHttpClientHandler(quicImplementationProvider: UseQuicImplementationProvider)); // First request uses HTTP/1 or HTTP/2 and receives an Alt-Svc either by header or (with HTTP/2) by frame. @@ -479,7 +506,7 @@ namespace System.Net.Http.Functional.Tests using HttpResponseMessage responseB = await client.SendAsync(requestB).WaitAsync(TimeSpan.FromSeconds(20)); Assert.Equal(HttpStatusCode.OK, responseB.StatusCode); - Assert.NotEqual(3, responseB.Version.Major); + Assert.Equal(3, responseB.Version.Major); } } @@ -777,14 +804,26 @@ namespace System.Net.Http.Functional.Tests /// /// These are public interop test servers for various QUIC and HTTP/3 implementations, - /// taken from https://github.com/quicwg/base-drafts/wiki/Implementations + /// taken from https://github.com/quicwg/base-drafts/wiki/Implementations and https://bagder.github.io/HTTP3-test/. /// public static TheoryData InteropUris() => new TheoryData { - { "https://quic.rocks:4433/" }, // Chromium - { "https://http3-test.litespeedtech.com:4433/" }, // LiteSpeed - { "https://quic.tech:8443/" } // Cloudflare + { "https://www.litespeedtech.com/" }, // LiteSpeed + { "https://quic.tech:8443/" }, // Cloudflare + { "https://quic.aiortc.org:443/" }, // aioquic + { "https://h2o.examp1e.net/" } // h2o/quicly + }; + + /// + /// These are public interop test servers for various QUIC and HTTP/3 implementations, + /// taken from https://github.com/quicwg/base-drafts/wiki/Implementations and https://bagder.github.io/HTTP3-test/. + /// + public static TheoryData InteropUrisWithContent() => + new TheoryData + { + { "https://cloudflare-quic.com/" }, // Cloudflare with content + { "https://pgjones.dev/" }, // aioquic with content }; } } -- 2.7.4