Fix hanging HTTP cancelation test. (#57573)
authorPavel Savara <pavelsavara@microsoft.com>
Tue, 17 Aug 2021 18:17:05 +0000 (20:17 +0200)
committerGitHub <noreply@github.com>
Tue, 17 Aug 2021 18:17:05 +0000 (13:17 -0500)
* fix hanging http cancelation test. On wasm, the loopback could never get to read the headers

* feedback

src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs

index 1cd8ede..9b697a5 100644 (file)
@@ -425,12 +425,12 @@ namespace System.Net.Http.Functional.Tests
                 {
                     await server.AcceptConnectionAsync(async connection =>
                     {
-                        cts.Cancel();
                         try
                         {
-                            await connection.ReadRequestHeaderAndSendResponseAsync();
+                            await connection.ReadRequestHeaderAsync();
                         }
                         catch { }
+                        cts.Cancel();
                     });
                 });
         }
@@ -592,12 +592,12 @@ namespace System.Net.Http.Functional.Tests
                 {
                     await server.AcceptConnectionAsync(async connection =>
                     {
-                        cts.Cancel();
                         try
                         {
-                            await connection.ReadRequestHeaderAndSendResponseAsync();
+                            await connection.ReadRequestHeaderAsync();
                         }
                         catch { }
+                        cts.Cancel();
                     });
                 });
         }
@@ -666,12 +666,12 @@ namespace System.Net.Http.Functional.Tests
                 {
                     await server.AcceptConnectionAsync(async connection =>
                     {
-                        cts.Cancel();
                         try
                         {
-                            await connection.ReadRequestHeaderAndSendResponseAsync();
+                            await connection.ReadRequestHeaderAsync();
                         }
                         catch { }
+                        cts.Cancel();
                     });
                 });
         }