예제 #1
0
        internal static async Task 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 = await GetEpListener(lp.Host, lp.Port, listener, lp.Secure).ConfigureAwait(false);

            epl.AddPrefix(lp, listener);
        }
예제 #2
0
        private static void AddPrefixInternal(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);
        }
예제 #3
0
        private static void RemovePrefixInternal(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, listener);
            }
            catch (SocketException)
            {
                // ignored
            }
        }
예제 #4
0
        private static async Task RemovePrefix(string prefix, HttpListener listener)
        {
            try
            {
                var lp = new ListenerPrefix(prefix);

                if (!lp.IsValid())
                {
                    return;
                }

                var epl = await GetEpListener(lp.Host, lp.Port, listener, lp.Secure).ConfigureAwait(false);

                epl.RemovePrefix(lp, listener);
            }
            catch (SocketException)
            {
                // ignored
            }
        }