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); }
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); }
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); }
public DetergentRootHttpHandler AddSubhandler(string regexMatch, IDetergentHttpHandler handler) { subhandlers.Add(new Regex(regexMatch, RegexOptions.Compiled | RegexOptions.IgnoreCase), handler); return(this); }
public DetergentRootHttpHandler AddSubhandler(string regexMatch, IDetergentHttpHandler handler) { subhandlers.Add(new Regex(regexMatch, RegexOptions.Compiled | RegexOptions.IgnoreCase), handler); return this; }