Skip to content

Commit

Permalink
update to http.server allow using ::, localhost, 0.0.0.0, * in all …
Browse files Browse the repository at this point in the history
…Ethernet interfaces.
  • Loading branch information
alec1o committed Nov 23, 2024
1 parent 9f81dfb commit e9196fc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/http/partials/Server/HTTP.ServerTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@ public Task Open(Uri host)
{
var server = new HttpListener();

var httpUrl = $"{Uri.UriSchemeHttp}{Uri.SchemeDelimiter}{host.Host}:{host.Port}/";
var hostScheme = host.Host.ToLower();

switch (hostScheme)
{
case "0.0.0.0":
case "localhost":
case "::":
case "*":
case ".":
hostScheme = "*";
break;
}

var httpUrl = $"{Uri.UriSchemeHttp}{Uri.SchemeDelimiter}{hostScheme}:{host.Port}/";

server.Prefixes.Add(httpUrl);

Expand Down

0 comments on commit e9196fc

Please sign in to comment.