void InnerRun(object state) { requestId = -1; broker = null; RequestReader rr = new RequestReader (client); if (rr.ShuttingDown) { Close (); server.Stop (); return; } string vhost = rr.Request.GetRequestHeader ("Host"); int port = -1; if (vhost != null) { int lead = vhost.IndexOf('['); int follow = lead >= 0 ? vhost.IndexOf(']') : -1; if (follow > lead) { //ipv6 address int colon = vhost.IndexOf("]:", StringComparison.Ordinal); if (colon != -1) { Int32.TryParse (vhost.Substring (colon + 2), out port); vhost = vhost.Substring(0, colon + 1); } } else { //ipv4 or hostname int colon = vhost.IndexOf (':'); if (colon != -1) { Int32.TryParse (vhost.Substring (colon + 1), out port); vhost = vhost.Substring (0, colon); } } if (port <= 0 || port > 65535) { //No port specified, Int32.TryParse failed or invalid port number port = 80; } } string vServerName = rr.Request.GetVirtualServerName (); if (vServerName == null) vServerName = vhost; VPathToHost vapp = null; string vpath = rr.GetUriPath (); string path = rr.GetPhysicalPath (); if (path == null) { vapp = server.GetApplicationForPath (vServerName, port, vpath, false); } else { vapp = GetOrCreateApplication (vServerName, port, path, vpath); } if (vapp == null) { rr.NotFound (); Stream.Close (); Stream = null; return; } ModMonoApplicationHost host = (ModMonoApplicationHost) vapp.AppHost; if (host == null) { rr.NotFound (); Stream.Close (); Stream = null; return; } modRequest = rr.Request; if (!server.SingleApplication) { broker = (ModMonoRequestBroker) vapp.RequestBroker; broker.UnregisterRequestEvent += new UnregisterRequestEventHandler (OnUnregisterRequest); requestId = broker.RegisterRequest (this); } host.ProcessRequest (requestId, modRequest.GetHttpVerbName(), modRequest.GetQueryString(), modRequest.GetUri(), modRequest.GetProtocol(), modRequest.GetLocalAddress(), modRequest.GetServerPort(), modRequest.GetRemoteAddress(), modRequest.GetRemotePort(), modRequest.GetRemoteName(), modRequest.GetAllHeaders(), modRequest.GetAllHeaderValues(), (requestId == -1) ? this : null); }
public RequestReader(Socket client) { Request = new ModMonoRequest(client); }
public RequestReader (Socket client) { Request = new ModMonoRequest (client); }
void InnerRun (object state) { requestId = -1; broker = null; RequestReader rr = new RequestReader (Stream); if (rr.ShuttingDown) { Close (); server.Stop (); return; } string vhost = rr.Request.GetRequestHeader ("Host"); int port = -1; if (vhost != null) { int colon = vhost.IndexOf (':'); if (colon != -1) { port = Int32.Parse (vhost.Substring (colon + 1)); vhost = vhost.Substring (0, colon); } else { port = 80; } } VPathToHost vapp = null; string vpath = rr.GetUriPath (); string path = rr.GetPhysicalPath (); if (path == null) { vapp = server.GetApplicationForPath (vhost, port, vpath, false); } else { vapp = GetOrCreateApplication (vhost, port, path, vpath); } if (vapp == null) { rr.Decline (); Stream.Close (); Stream = null; return; } ModMonoApplicationHost host = (ModMonoApplicationHost) vapp.AppHost; if (host == null) { rr.Decline (); Stream.Close (); Stream = null; return; } modRequest = rr.Request; broker = (ModMonoRequestBroker) vapp.RequestBroker; requestId = broker.RegisterRequest (this); host.ProcessRequest (requestId, modRequest.GetHttpVerbName(), modRequest.GetQueryString(), modRequest.GetUri(), modRequest.GetProtocol(), modRequest.GetLocalAddress(), modRequest.GetServerPort(), modRequest.GetRemoteAddress(), modRequest.GetRemotePort(), modRequest.GetRemoteName(), modRequest.GetAllHeaders(), modRequest.GetAllHeaderValues()); }
void InnerRun(object state) { requestId = -1; broker = null; RequestReader rr = new RequestReader(client); if (rr.ShuttingDown) { Close(); server.Stop(); return; } string vhost = rr.Request.GetRequestHeader("Host"); int port = -1; if (vhost != null) { int colon = vhost.IndexOf(':'); if (colon != -1) { port = Int32.Parse(vhost.Substring(colon + 1)); vhost = vhost.Substring(0, colon); } else { port = 80; } } string vServerName = rr.Request.GetVirtualServerName(); if (vServerName == null) { vServerName = vhost; } VPathToHost vapp = null; string vpath = rr.GetUriPath(); string path = rr.GetPhysicalPath(); if (path == null) { vapp = server.GetApplicationForPath(vServerName, port, vpath, false); } else { vapp = GetOrCreateApplication(vServerName, port, path, vpath); } if (vapp == null) { rr.NotFound(); Stream.Close(); Stream = null; return; } ModMonoApplicationHost host = (ModMonoApplicationHost)vapp.AppHost; if (host == null) { rr.NotFound(); Stream.Close(); Stream = null; return; } modRequest = rr.Request; if (!server.SingleApplication) { broker = (ModMonoRequestBroker)vapp.RequestBroker; broker.UnregisterRequestEvent += new UnregisterRequestEventHandler(OnUnregisterRequest); requestId = broker.RegisterRequest(this); } host.ProcessRequest(requestId, modRequest.GetHttpVerbName(), modRequest.GetQueryString(), modRequest.GetUri(), modRequest.GetProtocol(), modRequest.GetLocalAddress(), modRequest.GetServerPort(), modRequest.GetRemoteAddress(), modRequest.GetRemotePort(), modRequest.GetRemoteName(), modRequest.GetAllHeaders(), modRequest.GetAllHeaderValues(), (requestId == -1) ? this : null); }
void InnerRun(object state) { requestId = -1; broker = null; RequestReader rr = new RequestReader (client); if (rr.ShuttingDown) { Close (); server.Stop (); return; } string vhost = rr.Request.GetRequestHeader ("Host"); int port = -1; if (vhost != null) { if (vhost.Contains("[") && vhost.Contains("]")) { //ipv6 int colon = vhost.IndexOf ("]:"); if (colon != -1) { port = Int32.Parse (vhost.Substring (colon +1)); vhost = vhost.Substring( vhost.IndexOf('['), vhost.IndexOf(']') ); } else { port = 80; } } else { //ipv4 or hostname int colon = vhost.IndexOf (':'); if (colon != -1) { port = Int32.Parse (vhost.Substring (colon + 1)); vhost = vhost.Substring (0, colon); } else { port = 80; } } } string vServerName = rr.Request.GetVirtualServerName (); if (vServerName == null) vServerName = vhost; VPathToHost vapp = null; string vpath = rr.GetUriPath (); string path = rr.GetPhysicalPath (); if (path == null) { vapp = server.GetApplicationForPath (vServerName, port, vpath, false); } else { vapp = GetOrCreateApplication (vServerName, port, path, vpath); } if (vapp == null) { rr.NotFound (); Stream.Close (); Stream = null; return; } ModMonoApplicationHost host = (ModMonoApplicationHost) vapp.AppHost; if (host == null) { rr.NotFound (); Stream.Close (); Stream = null; return; } modRequest = rr.Request; if (!server.SingleApplication) { broker = (ModMonoRequestBroker) vapp.RequestBroker; broker.UnregisterRequestEvent += new UnregisterRequestEventHandler (OnUnregisterRequest); requestId = broker.RegisterRequest (this); } host.ProcessRequest (requestId, modRequest.GetHttpVerbName(), modRequest.GetQueryString(), modRequest.GetUri(), modRequest.GetProtocol(), modRequest.GetLocalAddress(), modRequest.GetServerPort(), modRequest.GetRemoteAddress(), modRequest.GetRemotePort(), modRequest.GetRemoteName(), modRequest.GetAllHeaders(), modRequest.GetAllHeaderValues(), (requestId == -1) ? this : null); }
public RequestReader (NetworkStream ns) { this.request = new ModMonoRequest (ns); }