Example #1
0
 public ModMonoWorkerRequest(int requestId, ModMonoRequestBroker requestBroker,
                             IApplicationHost appHost, string verb, string path,
                             string queryString, string protocol, string localAddress,
                             int serverPort, string remoteAddress, int remotePort,
                             string remoteName, string[] headers, string[] headerValues)
     : base(appHost)
 {
     this.requestId     = requestId;
     this.requestBroker = requestBroker;
     this.verb          = verb;
     this.appHost       = appHost;
     //this.protocol = protocol;
     // Don't let System.Web know if it's 1.1. This way apache handles the chunked
     // encoding for us, without sys.web interfering.
     this.protocol      = "HTTP/1.0";
     this.queryString   = queryString;
     this.path          = path;
     this.localAddress  = localAddress;
     this.serverPort    = serverPort;
     this.remoteAddress = remoteAddress;
     this.remotePort    = remotePort;
     this.remoteName    = remoteName;
     this.headers       = headers;
     this.headerValues  = headerValues;
 }
Example #2
0
        public ModMonoWorkerRequest(int requestId, ModMonoRequestBroker requestBroker,
					IApplicationHost appHost, string verb, string path,
					string queryString, string protocol, string localAddress,
					int serverPort, string remoteAddress, int remotePort,
					string remoteName, string[] headers, string[] headerValues)
            : base(appHost)
        {
            this.requestId = requestId;
            this.requestBroker = requestBroker;
            this.verb = verb;
            this.appHost = appHost;
            this.rawUrl = path;
            if (!String.IsNullOrEmpty (queryString))
                this.rawUrl += "?" + queryString;
            //this.protocol = protocol;
            // Don't let System.Web know if it's 1.1. This way apache handles the chunked
            // encoding for us, without sys.web interfering.
            this.protocol = "HTTP/1.0";
            this.queryString = queryString;
            this.path = path;
            this.localAddress = localAddress;
            this.serverPort = serverPort;
            this.remoteAddress = remoteAddress;
            this.remotePort = remotePort;
            this.remoteName = remoteName;
            this.headers = headers;
            this.headerValues = headerValues;
        }
Example #3
0
        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);
        }
Example #4
0
		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());
		}
Example #5
0
        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);
        }
Example #6
0
        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);
        }