From b13ea4cd548e560a5cfe32fedb9fef9a7a32f7bd Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Tue, 5 Mar 2019 17:43:59 +0000 Subject: [PATCH] Use localhost for HttpListener (dotnet/extensions#1206) Use localhost instead of 127.0.0.1 to fix dotnet/extensions#1205.\n\nCommit migrated from https://github.com/dotnet/extensions/commit/99b4ddbdbc86bffdafa76d7cac568b6b5ca46f1c --- src/Testing/test/HttpClientSlimTest.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Testing/test/HttpClientSlimTest.cs b/src/Testing/test/HttpClientSlimTest.cs index 42b19ece08..ede48243e5 100644 --- a/src/Testing/test/HttpClientSlimTest.cs +++ b/src/Testing/test/HttpClientSlimTest.cs @@ -4,7 +4,6 @@ using System; using System.Net; using System.Net.Http; -using System.Net.Sockets; using System.Text; using System.Threading.Tasks; using Xunit; @@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Testing { public class HttpClientSlimTest { - private static byte[] _defaultResponse = Encoding.ASCII.GetBytes("test"); + private static readonly byte[] _defaultResponse = Encoding.ASCII.GetBytes("test"); [Fact] public async Task GetStringAsyncHttp() @@ -79,7 +78,7 @@ namespace Microsoft.AspNetCore.Testing // HttpListener doesn't support requesting port 0 (dynamic). // Requesting port 0 from Sockets and then passing that to HttpListener is racy. // Just keep trying until we find a free one. - address = $"http://127.0.0.1:{random.Next(1024, ushort.MaxValue)}/"; + address = $"http://localhost:{random.Next(1024, ushort.MaxValue)}/"; listener.Prefixes.Add(address); listener.Start(); break;