コード例 #1
0
        private static void removePrefix(string uriPrefix, HttpListener httpListener)
        {
            ListenerPrefix listenerPrefix = new ListenerPrefix(uriPrefix);

            if (listenerPrefix.Path.IndexOf('%') != -1)
            {
                return;
            }
            if (listenerPrefix.Path.IndexOf("//", StringComparison.Ordinal) != -1)
            {
                return;
            }
            EndPointListener endPointListener = EndPointManager.getEndPointListener(IPAddress.Any, listenerPrefix.Port, httpListener, listenerPrefix.Secure);

            endPointListener.RemovePrefix(listenerPrefix, httpListener);
        }
コード例 #2
0
        private static void addPrefix(string uriPrefix, HttpListener httpListener)
        {
            ListenerPrefix listenerPrefix = new ListenerPrefix(uriPrefix);

            if (listenerPrefix.Path.IndexOf('%') != -1)
            {
                throw new HttpListenerException(400, "Invalid path.");
            }
            if (listenerPrefix.Path.IndexOf("//", StringComparison.Ordinal) != -1)
            {
                throw new HttpListenerException(400, "Invalid path.");
            }
            EndPointListener endPointListener = EndPointManager.getEndPointListener(IPAddress.Any, listenerPrefix.Port, httpListener, listenerPrefix.Secure);

            endPointListener.AddPrefix(listenerPrefix, httpListener);
        }