Use localhost for HttpListener (dotnet/extensions#1206)

Use localhost instead of 127.0.0.1 to fix dotnet/extensions#1205.\n\nCommit migrated from 99b4ddbdbc
This commit is contained in:
Martin Costello 2019-03-05 17:43:59 +00:00 committed by Chris Ross
parent 09b9a49da6
commit b13ea4cd54
1 changed files with 2 additions and 3 deletions

View File

@ -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;