internal static void AddPrefix(string p, HttpListener listener) { var lp = new ListenerPrefix(p); if (!lp.IsValid()) { throw new HttpListenerException(400, "Invalid path."); } // listens on all the interfaces if host name cannot be parsed by IPAddress. var epl = GetEpListener(lp.Host, lp.Port, listener, lp.Secure); epl.AddPrefix(lp, listener); }
private static void RemovePrefix(string prefix, HttpListener listener) { try { var lp = new ListenerPrefix(prefix); if (!lp.IsValid()) { return; } var epl = GetEpListener(lp.Host, lp.Port, listener, lp.Secure); epl.RemovePrefix(lp); } catch (SocketException) { // ignored } }