!fixup! bad merge of `Utilities`

This commit is contained in:
Doug Bunting 2019-09-20 22:43:29 -07:00
parent 24fe524029
commit 2aa3bcaec8
No known key found for this signature in database
GPG Key ID: EE41520987982C03
1 changed files with 9 additions and 22 deletions

View File

@ -116,30 +116,17 @@ namespace Microsoft.AspNetCore.Server.HttpSys
internal static IServer CreateDynamicHttpServer(string basePath, out string root, out string baseAddress, Action<HttpSysOptions> configureOptions, RequestDelegate app) internal static IServer CreateDynamicHttpServer(string basePath, out string root, out string baseAddress, Action<HttpSysOptions> configureOptions, RequestDelegate app)
{ {
lock (PortLock) var prefix = UrlPrefix.Create("http", "localhost", "0", basePath);
{
while (NextPort < MaxPort)
{
var port = NextPort++; var server = CreatePump(configureOptions);
var prefix = UrlPrefix.Create("http", "localhost", port, basePath); server.Features.Get<IServerAddressesFeature>().Addresses.Add(prefix.ToString());
root = prefix.Scheme + "://" + prefix.Host + ":" + prefix.Port; server.StartAsync(new DummyApplication(app), CancellationToken.None).Wait();
baseAddress = prefix.ToString();
var server = CreatePump(configureOptions); prefix = server.Listener.Options.UrlPrefixes.First(); // Has new port
server.Features.Get<IServerAddressesFeature>().Addresses.Add(baseAddress); root = prefix.Scheme + "://" + prefix.Host + ":" + prefix.Port;
try baseAddress = prefix.ToString();
{
server.StartAsync(new DummyApplication(app), CancellationToken.None).Wait(); return server;
return server;
}
catch (HttpSysException)
{
}
}
NextPort = BasePort;
}
throw new Exception("Failed to locate a free port.");
} }
internal static IServer CreateDynamicHttpsServer(out string baseAddress, RequestDelegate app) internal static IServer CreateDynamicHttpsServer(out string baseAddress, RequestDelegate app)