!fixup! bad merge of `Utilities`
This commit is contained in:
parent
24fe524029
commit
2aa3bcaec8
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue