コード例 #1
0
        public DetergentHttpListener(
            string uriPrefix,
            string applicationPath,
            IDetergentHttpHandler detergentHttpHandler)
        {
            if (uriPrefix == null)
                throw new ArgumentNullException("uriPrefix");
            if (applicationPath == null)
                throw new ArgumentNullException("applicationPath");
            if (detergentHttpHandler == null) throw new ArgumentNullException("detergentHttpHandler");

            this.uriPrefix = uriPrefix;
            this.applicationPath = applicationPath;
            this.detergentHttpHandler = detergentHttpHandler;
            httpListener = new HttpListener();

            applicationRootUrl = new Uri(new Uri(uriPrefix), applicationPath).ToString();
            if (false == applicationRootUrl.EndsWith("/", StringComparison.OrdinalIgnoreCase))
                applicationRootUrl = applicationRootUrl + '/';

            httpListener.Prefixes.Add(applicationRootUrl);

            DumpDiagnostics();

            httpListener.Start();
            IAsyncResult result = httpListener.BeginGetContext(WebRequestCallback, httpListener);
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            string requestId = IncidentIdGenerator.GenerateIncidentId();
            log4net.ThreadContext.Properties["requestId"] = requestId;

            internalHttpHttpHandler = (IDetergentHttpHandler)context.Application[DetergentWebHttpHandlerId];

            if (internalHttpHttpHandler == null)
                throw new ConfigurationErrorsException("DetergentWebHttpHandler does not have a configured inner handler");

            WebHttpContext contextWrapper = new WebHttpContext(context);
            CurrentHttpContext.Current = contextWrapper;
            contextWrapper.SetRequestId(requestId);

            IHttpResponse response = internalHttpHttpHandler.ProcessRequest(contextWrapper);
            if (response != null)
                response.Send(contextWrapper);
        }
コード例 #3
0
        public DetergentHttpListener(
            string uriPrefix,
            string applicationPath,
            IDetergentHttpHandler detergentHttpHandler)
        {
            if (uriPrefix == null)
            {
                throw new ArgumentNullException("uriPrefix");
            }
            if (applicationPath == null)
            {
                throw new ArgumentNullException("applicationPath");
            }
            if (detergentHttpHandler == null)
            {
                throw new ArgumentNullException("detergentHttpHandler");
            }

            this.uriPrefix            = uriPrefix;
            this.applicationPath      = applicationPath;
            this.detergentHttpHandler = detergentHttpHandler;
            httpListener = new HttpListener();

            applicationRootUrl = new Uri(new Uri(uriPrefix), applicationPath).ToString();
            if (false == applicationRootUrl.EndsWith("/", StringComparison.OrdinalIgnoreCase))
            {
                applicationRootUrl = applicationRootUrl + '/';
            }

            httpListener.Prefixes.Add(applicationRootUrl);

            DumpDiagnostics();

            httpListener.Start();
            IAsyncResult result = httpListener.BeginGetContext(WebRequestCallback, httpListener);
        }
コード例 #4
0
 public DetergentRootHttpHandler AddSubhandler(string regexMatch, IDetergentHttpHandler handler)
 {
     subhandlers.Add(new Regex(regexMatch, RegexOptions.Compiled | RegexOptions.IgnoreCase), handler);
     return(this);
 }
コード例 #5
0
 public DetergentRootHttpHandler AddSubhandler(string regexMatch, IDetergentHttpHandler handler)
 {
     subhandlers.Add(new Regex(regexMatch, RegexOptions.Compiled | RegexOptions.IgnoreCase), handler);
     return this;
 }