diff --git a/src/Common/tests/System/Net/Configuration.Http.cs b/src/Common/tests/System/Net/Configuration.Http.cs index 81961a637ebc..f4763451beec 100644 --- a/src/Common/tests/System/Net/Configuration.Http.cs +++ b/src/Common/tests/System/Net/Configuration.Http.cs @@ -8,7 +8,7 @@ public static partial class Configuration { public static partial class Http { - private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net"; + private static readonly string DefaultAzureServer = "corefx-net-http11.azurewebsites.net"; public static string Host => GetValue("COREFX_HTTPHOST", DefaultAzureServer); diff --git a/src/Common/tests/System/Net/Configuration.Security.cs b/src/Common/tests/System/Net/Configuration.Security.cs index b5a3e5ccea13..8fd095077ab8 100644 --- a/src/Common/tests/System/Net/Configuration.Security.cs +++ b/src/Common/tests/System/Net/Configuration.Security.cs @@ -8,7 +8,7 @@ public static partial class Configuration { public static partial class Security { - private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net"; + private static readonly string DefaultAzureServer = "corefx-net-http11.azurewebsites.net"; public static string ActiveDirectoryName => GetValue("COREFX_NET_AD_DOMAINNAME"); diff --git a/src/Common/tests/System/Net/Configuration.cs b/src/Common/tests/System/Net/Configuration.cs index 1aa664d2aa92..5587d1fd2817 100644 --- a/src/Common/tests/System/Net/Configuration.cs +++ b/src/Common/tests/System/Net/Configuration.cs @@ -7,7 +7,7 @@ namespace System.Net.Test.Common public static partial class Configuration { #pragma warning disable 414 - private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net"; + private static readonly string DefaultAzureServer = "corefx-net-http11.azurewebsites.net"; #pragma warning restore 414 private static string GetValue(string envName, string defaultValue=null) diff --git a/src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.ServerCertificates.cs b/src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.ServerCertificates.cs index 980155da22e8..f3fc264e7fde 100644 --- a/src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.ServerCertificates.cs +++ b/src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.ServerCertificates.cs @@ -311,6 +311,7 @@ public async Task NoCallback_BadCertificate_ThrowsException(string url) } } + [ActiveIssue(41108)] [SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "UAP doesn't allow revocation checking to be turned off")] [OuterLoop] // TODO: Issue #11345 [ConditionalFact(nameof(ClientSupportsDHECipherSuites), nameof(BackendSupportsX509Chain))] diff --git a/src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs b/src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs index cc1cfeb44a4a..032cfaa56017 100644 --- a/src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs +++ b/src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs @@ -2701,17 +2701,16 @@ public async Task PostAsync_ReuseRequestContent_Success(Uri remoteServer) [InlineData(HttpStatusCode.MethodNotAllowed, "")] public async Task GetAsync_CallMethod_ExpectedStatusLine(HttpStatusCode statusCode, string reasonPhrase) { - using (HttpClient client = CreateHttpClient()) + await LoopbackServer.CreateClientAndServerAsync(async uri => { - using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.StatusCodeUri( - false, - (int)statusCode, - reasonPhrase))) + using (HttpClient client = CreateHttpClient()) + using (HttpResponseMessage response = await client.GetAsync(uri)) { Assert.Equal(statusCode, response.StatusCode); Assert.Equal(reasonPhrase, response.ReasonPhrase); } - } + }, server => server.AcceptConnectionSendCustomResponseAndCloseAsync( + $"HTTP/1.1 {(int)statusCode} {reasonPhrase}\r\nContent-Length: 0\r\n\r\n")); } #endregion diff --git a/src/System.Net.Requests/tests/HttpWebRequestTest.cs b/src/System.Net.Requests/tests/HttpWebRequestTest.cs index 3745049b941b..de37415ffa53 100644 --- a/src/System.Net.Requests/tests/HttpWebRequestTest.cs +++ b/src/System.Net.Requests/tests/HttpWebRequestTest.cs @@ -456,31 +456,35 @@ public void KeepAlive_SetThenGetBoolean_ValuesMatch(Uri remoteServer) [InlineData(false)] [InlineData(true)] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19225")] - public void KeepAlive_CorrectConnectionHeaderSent(bool? keepAlive) + public async Task KeepAlive_CorrectConnectionHeaderSent(bool? keepAlive) { - HttpWebRequest request = WebRequest.CreateHttp(Test.Common.Configuration.Http.RemoteEchoServer); - - if (keepAlive.HasValue) + await LoopbackServer.CreateServerAsync(async (server, url) => { - request.KeepAlive = keepAlive.Value; - } + HttpWebRequest request = WebRequest.CreateHttp(url); + request.Proxy = null; // Don't use a proxy since it might interfere with the Connection: headers. + if (keepAlive.HasValue) + { + request.KeepAlive = keepAlive.Value; + } - using (var response = (HttpWebResponse)request.GetResponse()) - using (var body = new StreamReader(response.GetResponseStream())) - { - string content = body.ReadToEnd(); + Task getResponseTask = request.GetResponseAsync(); + Task> serverTask = server.AcceptConnectionSendResponseAndCloseAsync(); + + await TaskTimeoutExtensions.WhenAllOrAnyFailed(new Task[] { getResponseTask, serverTask }); + + List requestLines = await serverTask; if (!keepAlive.HasValue || keepAlive.Value) { - // Validate that the request doesn't contain Connection: "close", but we can't validate - // that it does contain Connection: "keep-alive", as that's optional as of HTTP 1.1. - Assert.DoesNotContain("\"Connection\": \"close\"", content, StringComparison.OrdinalIgnoreCase); + // Validate that the request doesn't contain "Connection: close", but we can't validate + // that it does contain "Connection: Keep-Alive", as that's optional as of HTTP 1.1. + Assert.DoesNotContain("Connection: close", requestLines, StringComparer.OrdinalIgnoreCase); } else { - Assert.Contains("\"Connection\": \"close\"", content, StringComparison.OrdinalIgnoreCase); - Assert.DoesNotContain("\"Keep-Alive\"", content, StringComparison.OrdinalIgnoreCase); + Assert.Contains("Connection: close", requestLines, StringComparer.OrdinalIgnoreCase); + Assert.DoesNotContain("Keep-Alive", requestLines, StringComparer.OrdinalIgnoreCase); } - } + }); } [Theory, MemberData(nameof(EchoServers))] diff --git a/src/System.Net.WebClient/tests/WebClientTest.cs b/src/System.Net.WebClient/tests/WebClientTest.cs index 45d32915da65..1d11427f40b0 100644 --- a/src/System.Net.WebClient/tests/WebClientTest.cs +++ b/src/System.Net.WebClient/tests/WebClientTest.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Collections.Specialized; using System.IO; using System.Linq; @@ -15,6 +16,8 @@ namespace System.Net.Tests { + using Configuration = System.Net.Test.Common.Configuration; + public class WebClientTest { [Fact] @@ -393,21 +396,26 @@ public static async Task RequestHeaders_AddDisallowedHeaderAndSendRequest_Throws await Assert.ThrowsAsync(() => wc.DownloadStringTaskAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer)); } - [OuterLoop("Networking test talking to remote server: issue #11345")] + public static IEnumerable RequestHeaders_AddHostHeaderAndSendRequest_ExpectedResult_MemberData() + { + yield return new object[] { $"http://{Configuration.Http.Host}", true }; + yield return new object[] { Configuration.Http.Host, false }; + } + + [OuterLoop("Uses external servers")] [Theory] - [InlineData("http://localhost", true)] - [InlineData("localhost", false)] + [MemberData(nameof(RequestHeaders_AddHostHeaderAndSendRequest_ExpectedResult_MemberData))] public static async Task RequestHeaders_AddHostHeaderAndSendRequest_ExpectedResult(string hostHeaderValue, bool throwsWebException) { var wc = new WebClient(); wc.Headers["Host"] = hostHeaderValue; if (throwsWebException) { - await Assert.ThrowsAsync(() => wc.DownloadStringTaskAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer)); + await Assert.ThrowsAsync(() => wc.DownloadStringTaskAsync(Configuration.Http.RemoteEchoServer)); } else { - await wc.DownloadStringTaskAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer); + await wc.DownloadStringTaskAsync(Configuration.Http.RemoteEchoServer); } } diff --git a/src/System.Net.WebSockets.Client/tests/CloseTest.cs b/src/System.Net.WebSockets.Client/tests/CloseTest.cs index 732bd97607d2..5bb9f323a70f 100644 --- a/src/System.Net.WebSockets.Client/tests/CloseTest.cs +++ b/src/System.Net.WebSockets.Client/tests/CloseTest.cs @@ -17,6 +17,7 @@ public class CloseTest : ClientWebSocketTestBase { public CloseTest(ITestOutputHelper output) : base(output) { } + [ActiveIssue(36016)] [OuterLoop] // TODO: Issue #11345 [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_ServerInitiatedClose_Success(Uri server) @@ -194,6 +195,7 @@ public async Task CloseOutputAsync_ClientInitiated_CanReceive_CanClose(Uri serve } } + [ActiveIssue(36016)] [OuterLoop] // TODO: Issue #11345 [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_ServerInitiated_CanSend(Uri server) diff --git a/src/System.Net.WebSockets.Client/tests/ConnectTest.cs b/src/System.Net.WebSockets.Client/tests/ConnectTest.cs index 8f75de2a2328..1bfaabfd3731 100644 --- a/src/System.Net.WebSockets.Client/tests/ConnectTest.cs +++ b/src/System.Net.WebSockets.Client/tests/ConnectTest.cs @@ -92,9 +92,9 @@ public async Task ConnectAsync_AddHostHeader_Success() { Uri server = System.Net.Test.Common.Configuration.WebSockets.RemoteEchoServer; - // Send via the physical address such as "corefx-net.cloudapp.net" - // Set the Host header to logical address like "subdomain.corefx-net.cloudapp.net" - // Verify the scenario works and the remote server received "Host: subdomain.corefx-net.cloudapp.net" + // Send via the physical address such as "corefx-net-http11.azurewebsites.net" + // Set the Host header to logical address like "subdomain.corefx-net-http11.azurewebsites.net" + // Verify the scenario works and the remote server received "Host: subdomain.corefx-net-http11.azurewebsites.net" string logicalHost = "subdomain." + server.Host; using (var cws = new ClientWebSocket())