Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 9a20b64

Browse files
hughbestephentoub
authored andcommitted
Revert fix no exception thrown listening to an already registered host/port …
1 parent 7eea71f commit 9a20b64

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/System.Net.HttpListener/src/System/Net/Managed/HttpEndPointManager.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,12 @@ private static void AddPrefixInternal(string p, HttpListener listener)
102102
throw new HttpListenerException((int)HttpStatusCode.BadRequest, SR.net_invalid_path);
103103

104104
// listens on all the interfaces if host name cannot be parsed by IPAddress.
105-
HttpEndPointListener epl = GetEPListener(lp.Host, lp.Port, listener, lp.Secure, out bool alreadyExists);
106-
if (alreadyExists)
107-
{
108-
throw new HttpListenerException(98, SR.Format(SR.net_listener_already, p));
109-
}
105+
HttpEndPointListener epl = GetEPListener(lp.Host, lp.Port, listener, lp.Secure);
110106
epl.AddPrefix(lp, listener);
111107
}
112108

113-
private static HttpEndPointListener GetEPListener(string host, int port, HttpListener listener, bool secure, out bool alreadyExists)
109+
private static HttpEndPointListener GetEPListener(string host, int port, HttpListener listener, bool secure)
114110
{
115-
alreadyExists = false;
116-
117111
IPAddress addr;
118112
if (host == "*")
119113
addr = IPAddress.Any;
@@ -146,7 +140,6 @@ private static HttpEndPointListener GetEPListener(string host, int port, HttpLis
146140
HttpEndPointListener epl = null;
147141
if (p.ContainsKey(port))
148142
{
149-
alreadyExists = true;
150143
epl = p[port];
151144
}
152145
else
@@ -208,7 +201,7 @@ private static void RemovePrefixInternal(string prefix, HttpListener listener)
208201
if (lp.Path.IndexOf("//", StringComparison.Ordinal) != -1)
209202
return;
210203

211-
HttpEndPointListener epl = GetEPListener(lp.Host, lp.Port, listener, lp.Secure, out bool ignored);
204+
HttpEndPointListener epl = GetEPListener(lp.Host, lp.Port, listener, lp.Secure);
212205
epl.RemovePrefix(lp, listener);
213206
}
214207
}

0 commit comments

Comments
 (0)