public HttpWorkerRequestImpl(HttpContextBase context, HttpServerSettings settings) : base(context.Request.Url.LocalPath, TrimQuery(context.Request.Url.Query), null) { _context = context; }
public HttpListenerImpl(IHttpHandler app, HttpServerSettings settings) { _app = app; _settings = settings; _listener = new HttpListener(); _listener.Prefixes.Add(string.Format(@"http://+:{0}/", settings.Port)); }
public HttpListenerContextImpl(HttpListenerContext context, HttpServerSettings settings) { _context = context; _settings = settings; _request = new RequestImpl(context.Request); _response = new ResponseImpl(context.Response); }
public HttpServer(IHttpHandler app, HttpServerSettings settings) { if (app == null) throw new ArgumentNullException("app"); if (settings == null) throw new ArgumentNullException("settings"); // init asp.net host if (settings.AspNetHost) { var appHost = new AppHost(settings); appHost.Init(); } IHttpListener listener; switch (settings.Mode) { case HttpServerMode.TcpListener: listener = new TcpListenerImpl(app, settings); break; case HttpServerMode.HttpListener: listener = new HttpListenerImpl(app, settings); break; default: throw new ArgumentOutOfRangeException(); } _listener = listener; _listener.Start(); _listenerThread = new Thread(Listen); _listenerThread.Start(); }
public HttpWorkerRequestImpl(HttpListenerContext context, HttpServerSettings settings) : base(context.Request.Url.LocalPath, TrimQuery(context.Request.Url.Query), null) { _listenerContext = context; _context = new HttpListenerContextImpl(context, settings); }
public HttpWorkerRequestImpl(HttpContextBase context, HttpServerSettings settings) : base( context.Request.Url.LocalPath, TrimQuery(context.Request.Url.Query), null) { _context = context; }
public HttpWorkerRequestImpl(HttpContextBase context, HttpServerSettings settings) : base(context.Request.Url.LocalPath, TrimQuery(context.Request.Url.Query), null) { _context = context; _url = context.Request.Url.ToString(); _localPort = settings.Port; }
public HttpWorkerRequestImpl(HttpListenerContext context, HttpServerSettings settings) : base( context.Request.Url.LocalPath, TrimQuery(context.Request.Url.Query), null) { _listenerContext = context; _context = new HttpListenerContextImpl(context, settings); }
public AppHost(HttpServerSettings settings) { if (settings == null) throw new ArgumentNullException("settings"); _settings = settings; InitDomain(settings); InitHostingEnvironment(); }
public TcpListenerImpl(IHttpHandler handler, HttpServerSettings settings) { if (handler == null) throw new ArgumentNullException("handler"); if (settings == null) throw new ArgumentNullException("settings"); _handler = handler; _settings = settings; // TODO endpoint setting _listener = new TcpListener(new IPEndPoint(IPAddress.Loopback, settings.Port)); }
public AppHost(HttpServerSettings settings) { if (settings == null) { throw new ArgumentNullException("settings"); } _settings = settings; InitDomain(settings); InitHostingEnvironment(); }
public static void InitDomain(HttpServerSettings settings) { var uniqueAppString = string.Format( CultureInfo.InvariantCulture, "{0}{1}:{2}", settings.VirtualDir, settings.PhisycalDir, settings.Port) .ToLowerInvariant(); var appId = (uniqueAppString.GetHashCode()).ToString("x", CultureInfo.InvariantCulture); var domain = Thread.GetDomain(); domain.SetData(".appDomain", "express-domain"); domain.SetData(".appId", appId); domain.SetData(".appPath", settings.PhisycalDir); domain.SetData(".appVPath", settings.VirtualDir); domain.SetData(".domainId", appId); }
public TcpListenerImpl(IHttpHandler handler, HttpServerSettings settings) { if (handler == null) { throw new ArgumentNullException("handler"); } if (settings == null) { throw new ArgumentNullException("settings"); } _handler = handler; _settings = settings; // TODO endpoint setting _listener = new TcpListener(new IPEndPoint(IPAddress.Loopback, settings.Port)); }
public HttpRequestImpl(HttpContextImpl context, IHttpChannel channel, HttpServerSettings settings) { _context = context; Method = channel.Method; var path = channel.Path; if (!path.StartsWith("/")) path = "/" + path; Uri = new Uri(string.Format("http://localhost:{0}{1}", settings.Port, path)); _headers.AddRange( from key in channel.Headers.AllKeys select new KeyValuePair<string, string>(key, channel.Headers[key]) ); var len = _headers.GetContentLength(); Body = len > 0 ? channel.Body : new MemoryStream(new byte[0], false); }
public static void ProcessRequest(this IHttpChannel channel, IHttpHandler handler, HttpServerSettings settings) { var context = new HttpContextImpl(channel, settings); var res = context.Response; using (res.OutputStream) { try { var app = handler as ExpressApplication; if (app != null) { if (!app.Process(context)) { res.StatusCode = (int)HttpStatusCode.NotFound; res.StatusDescription = "Not found"; res.ContentType = "text/plain"; res.Write("Resource not found!"); } res.Flush(); res.End(); } else { var workerRequest = new HttpWorkerRequestImpl(context, settings); handler.ProcessRequest(new HttpContext(workerRequest)); workerRequest.EndOfRequest(); } } catch (Exception e) { Console.Error.WriteLine(e); res.StatusCode = (int)HttpStatusCode.InternalServerError; res.ContentType = "text/plain"; res.Write(e.ToString()); } } }
public HttpServer(IHttpHandler app, HttpServerSettings settings) { if (app == null) { throw new ArgumentNullException("app"); } if (settings == null) { throw new ArgumentNullException("settings"); } // init asp.net host if (settings.AspNetHost) { var appHost = new AppHost(settings); appHost.Init(); } IHttpListener listener; switch (settings.Mode) { case HttpServerMode.TcpListener: listener = new TcpListenerImpl(app, settings); break; case HttpServerMode.HttpListener: listener = new HttpListenerImpl(app, settings); break; default: throw new ArgumentOutOfRangeException(); } _listener = listener; _listener.Start(); _listenerThread = new Thread(Listen); _listenerThread.Start(); }
public HttpRequestImpl(HttpContextImpl context, IHttpChannel channel, HttpServerSettings settings) { _context = context; Method = channel.Method; var path = channel.Path; if (!path.StartsWith("/")) { path = "/" + path; } Uri = new Uri(string.Format("http://localhost:{0}{1}", settings.Port, path)); _headers.AddRange( from key in channel.Headers.AllKeys select new KeyValuePair <string, string>(key, channel.Headers[key]) ); var len = _headers.GetContentLength(); Body = len > 0 ? channel.Body : new MemoryStream(new byte[0], false); }
public HttpContextImpl(IHttpChannel channel, HttpServerSettings settings) { ServerSettings = settings; _request = new HttpRequestImpl(this, channel, settings); _response = new HttpResponseImpl(channel); }
public HttpContextImpl(IHttpChannel channel, HttpServerSettings settings) { _request = new HttpRequestImpl(this, channel, settings); _response = new HttpResponseImpl(channel); }