Beispiel #1
0
 public WorkerRequest(Responder responder, ApplicationHost appHost) : base(appHost)
 {
     this.responder = responder;
     input_data     = responder.InputData;
     try {
         Paths.GetPathsFromUri(appHost, GetHttpVerbName(), GetFilePath(), out file_path, out path_info);
     } catch {
         path_info = null;
         file_path = null;
     }
 }
Beispiel #2
0
		public WorkerRequest (Responder responder, ApplicationHost appHost) : base (appHost)
		{
			this.responder = responder;
			input_data = responder.InputData;
			try {
				Paths.GetPathsFromUri (appHost, GetHttpVerbName (), GetFilePath (), out file_path, out path_info);
			} catch {
				path_info = null;
				file_path = null;
			}
		}
Beispiel #3
0
        public int Process()
        {
            // Uncommenting the following lines will cause the page
            // + headers to be rendered as plain text. (Pretty sweet
            // for debugging.)

            /*
             *      request.SendOutputText ("Content-type: text/plain\r\n\r\n");
             *      request.SendOutputText ("Output:\r\n");
             *      request.SendOutputText (Path + "\r\n");
             *      request.SendOutputText (PhysicalPath + "\r\n");
             */

            ApplicationHost appHost = request.ApplicationHost;

            // If the application host is null, the server was
            // unable to determine a sane plan. Alert the client.
            if (appHost == null)
            {
                request.SendOutputText(string.Format(error500,
                                                     HostName, PortNumber,
                                                     Path, PhysicalPath));
                return(-1);
            }

            try {
                appHost.ProcessRequest(this);
            } catch (Exception e) {
                Logger.Write(LogLevel.Error,
                             "ERROR PROCESSING REQUEST: " + e);
                return(-1);
            }

            // MIN_VALUE means don't close.
            return(int.MinValue);
        }
Beispiel #4
0
 public WorkerRequest(Responder responder, ApplicationHost appHost)
     : base(appHost)
 {
     this.responder = responder;
     input_data = responder.InputData;
 }
Beispiel #5
0
 public WorkerRequest(Responder responder, ApplicationHost appHost) : base(appHost)
 {
     this.responder = responder;
     input_data     = responder.InputData;
 }
Beispiel #6
0
        void ParseParameterData()
        {
            string redirectUrl;
            string pathInfo = GetParameter ("PATH_INFO");
            string pathTranslated = GetParameter ("PATH_TRANSLATED");
            VPathToHost vapp;
            if (String.IsNullOrEmpty(pathTranslated) ||
                String.IsNullOrEmpty(pathInfo) || pathInfo [0] != '/' ||
                (null != (redirectUrl = GetParameter ("REDIRECT_URL")) && redirectUrl.Length != 0 && pathInfo != redirectUrl)) {
                // Only consider REDIRECT_URL if it actually contains
                // something, since it may not always be present (depending
                // on installed Apache modules & setup).  Also, never allow
                // PATH_INFO to be null (nor PATH_TRANSLATED), even for
                // cases where this method is mostly short-circuited.
                if (pathInfo == null)
                    SetParameter ("PATH_INFO", String.Empty);
                if (pathTranslated == null)
                    SetParameter ("PATH_TRANSLATED", String.Empty);
                vapp = WebServer.FastCgi.Server.GetApplicationForPath (HostName, PortNumber, Path, PhysicalPath);
                if (vapp == null)
                    Logger.Write (LogLevel.Debug, "Couldn't find vapp.");
                else
                    ApplicationHost = vapp.AppHost as ApplicationHost;
                return;
            }

            // At this point we have:  (with REDIRECT_URL being optional)
            //
            // REDIRECT_URL=/dir/test.aspx/foo
            // PATH_INFO=/dir/test.aspx/foo
            // PATH_TRANSLATED=/srv/www/htdocs/dir/test.aspx/foo
            // SCRIPT_NAME=/cgi-bin/fastcgi-mono-server
            // SCRIPT_FILENAME=/srv/www/cgi-bin/fastcgi-mono-server

            string virtPath = pathInfo;
            string physPath = pathTranslated;
            string virtPathInfo = String.Empty;
            string physPathInfo = String.Empty;
            try {
                vapp = WebServer.FastCgi.Server.GetApplicationForPath (
                    HostName, PortNumber, virtPath, physPath);
                if (vapp == null)
                    return;  // Set values in finally
                ApplicationHost = vapp.AppHost as ApplicationHost;
                if (ApplicationHost == null)
                    return;  // Set values in finally

                // Split the virtual path and virtual path-info
                string verb = GetParameter ("REQUEST_METHOD");
                if (String.IsNullOrEmpty(verb))
                    verb = "GET";  // For the sake of paths, assume a default
                ApplicationHost.GetPathsFromUri (verb, pathInfo, out virtPath, out virtPathInfo);
                if (virtPathInfo == null)
                    virtPathInfo = String.Empty;
                if (virtPath == null)
                    virtPath = String.Empty;

                // Re-map the physical path
                physPath = ApplicationHost.MapPath (virtPath) ?? String.Empty;

                // Re-map the physical path-info
                string relaPathInfo = virtPathInfo;
                if (relaPathInfo.Length != 0 && IOPath.DirectorySeparatorChar != '/')
                    relaPathInfo = relaPathInfo.Replace ('/', IOPath.DirectorySeparatorChar);
                while (relaPathInfo.Length > 0 && relaPathInfo[0] == IOPath.DirectorySeparatorChar) {
                    relaPathInfo = relaPathInfo.Substring (1);
                }
                if (physPath.Length == 0) {
                    physPathInfo = relaPathInfo;
                    return;  // Set values in finally
                }
                string physRoot = physPath;
                try {
                    if (ApplicationHost.VirtualFileExists (virtPath)) {
                        physRoot = IOPath.GetDirectoryName (physRoot) ?? String.Empty;
                    }
                } catch {
                    // Assume virtPath, physPath & physRoot
                    // specify directories (and not files)
                }
                physPathInfo = IOPath.Combine (physRoot, relaPathInfo);
            } finally {
                // Now, if all went well, we set:
                //
                // SCRIPT_NAME=/dir/test.aspx
                // SCRIPT_FILENAME=/srv/www/htdocs/dir/test.aspx
                // PATH_INFO=/foo
                // PATH_TRANSLATED=/srv/www/htdocs/dir/foo

                SetParameter ("SCRIPT_NAME", virtPath);
                SetParameter ("SCRIPT_FILENAME", physPath);
                SetParameter ("PATH_INFO", virtPathInfo);
                SetParameter ("PATH_TRANSLATED", physPathInfo);
            }
        }