2002-12-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Wed, 18 Dec 2002 02:17:17 +0000 (02:17 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Wed, 18 Dec 2002 02:17:17 +0000 (02:17 -0000)
* System.Web/HttpApplicationFactory.cs: add the context as parameter
when building the application Type.

* System.Web/HttpCookie.cs: new internal constructor.
* System.Web/HttpCookieCollection.cs: new internal method to make a
cookie expire.

* System.Web/HttpRequest.cs: MapPath fixes.
* System.Web/HttpResponse.cs: implemented ApplyAppPathModifier.
* System.Web/HttpRuntime.cs: fixed typo in AppDomainAppVirtualPath.
* System.Web.Compilation/AspGenerator.cs: now it uses the current
HttpContext when creating user controls. TemplateSourceDirectory is no
longer a dummy value.

* System.Web.Compilation/GlobalAsaxCompiler.cs:
* System.Web.Compilation/PageCompiler.cs:
* System.Web.Compilation/UserControlCompiler.cs: set the context which
will be used to locate the files.

* System.Web.UI/BaseParser.cs: use MapPath and context to locate files.
* System.Web.UI/Control.cs: implemented MapPathSecure.
* System.Web.UI/TemplateControl.cs: use UrlUtils to generate the path.
* System.Web.UI/TemplateControlParser.cs: use the context and MapPath.
* System.Web.UI/UserControl.cs: implemented MapPath.
* System.Web.UI/UserControlParser.cs: added context parameter to
constructor.
* System.Web.Util/PathUtil.cs: removed.
* System.Web.Util/UrlUtils.cs: fixed Combine to handle '~'.

svn path=/trunk/mcs/; revision=9737

23 files changed:
mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
mcs/class/System.Web/System.Web.Compilation/ChangeLog
mcs/class/System.Web/System.Web.Compilation/GlobalAsaxCompiler.cs
mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs
mcs/class/System.Web/System.Web.Compilation/UserControlCompiler.cs
mcs/class/System.Web/System.Web.UI/BaseParser.cs
mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/Control.cs
mcs/class/System.Web/System.Web.UI/TemplateControl.cs
mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs
mcs/class/System.Web/System.Web.UI/UserControl.cs
mcs/class/System.Web/System.Web.UI/UserControlParser.cs
mcs/class/System.Web/System.Web.Util/ChangeLog
mcs/class/System.Web/System.Web.Util/PathUtil.cs [deleted file]
mcs/class/System.Web/System.Web.Util/UrlUtils.cs
mcs/class/System.Web/System.Web/ChangeLog
mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
mcs/class/System.Web/System.Web/HttpCookie.cs
mcs/class/System.Web/System.Web/HttpCookieCollection.cs
mcs/class/System.Web/System.Web/HttpRequest.cs
mcs/class/System.Web/System.Web/HttpResponse.cs
mcs/class/System.Web/System.Web/HttpRuntime.cs
mcs/class/System.Web/list

index 3c464a6ce8497d39bfe568b05e3abd8b44e91065..c5058fe2d21c15f78d9cb3fdcf6d7c7baa246a1a 100644 (file)
@@ -325,6 +325,8 @@ class AspGenerator
        bool isUserControl;
        bool isApplication;
 
+       HttpContext context;
+
        enum UserControlResult
        {
                OK = 0,
@@ -397,6 +399,11 @@ class AspGenerator
                }
        }
        
+       internal HttpContext Context {
+               get { return context; }
+               set { context = value; }
+       }
+       
        public void AddInterface (string iface)
        {
                if (interfaces == "") {
@@ -581,8 +588,7 @@ class AspGenerator
                                throw new ApplicationException ("Source file extension for controls " + 
                                                                "must be .ascx");
 
-                       string srcLocation = PathUtil.Combine (null, src);
-                       UserControlData data = GenerateUserControl (srcLocation);
+                       UserControlData data = GenerateUserControl (src, Context);
                        switch (data.result) {
                        case UserControlResult.OK:
                                prolog.AppendFormat ("\tusing {0};\n", "ASP");
@@ -1728,6 +1734,21 @@ class AspGenerator
                }
        }
 
+       private string GetTemplateDirectory ()
+       {
+               string templatePath = Path.GetDirectoryName (fullPath);
+               string appPath = Path.GetDirectoryName (HttpRuntime.AppDomainAppPath);
+
+               if (templatePath == appPath)
+                       return "/";
+
+               templatePath = templatePath.Substring (appPath.Length);
+               if (Path.DirectorySeparatorChar != '/')
+                       templatePath = templatePath.Replace (Path.DirectorySeparatorChar, '/');
+                       
+               return templatePath;
+       }
+
        private void End ()
        {
                classDecl = "\tpublic class " + className + " : " + parent + interfaces + " {\n"; 
@@ -1765,12 +1786,11 @@ class AspGenerator
                                "\t\tprotected System.Web.HttpApplication ApplicationInstance\n\t\t{\n" +
                                "\t\t\tget { return (System.Web.HttpApplication) this.Context.ApplicationInstance; }\n" +
                                "\t\t}\n\n");
-                       //FIXME: add TemplateSourceDirectory: don't know what for...yet!
-                       //FIXME: it should be the path from the root where the file resides
+
                        constructor.AppendFormat (
                                "\t\tpublic override string TemplateSourceDirectory\n\t\t{{\n" +
                                "\t\t\tget {{ return \"{0}\"; }}\n" +
-                               "\t\t}}\n\n", Path.GetDirectoryName (fullPath)); // FIXME: should be rooted on .appVPath
+                               "\t\t}}\n\n", GetTemplateDirectory ());
 
                        epilog.Append ("\n\t\tprotected override void FrameworkInitialize ()\n\t\t{\n" +
                                        "\t\t\tthis.__BuildControlTree (this);\n");
@@ -1832,17 +1852,12 @@ class AspGenerator
                public string assemblyName;
        }
 
-       private static UserControlData GenerateUserControl (string src)
+       private static UserControlData GenerateUserControl (string src, HttpContext context)
        {
                UserControlData data = new UserControlData ();
                data.result = UserControlResult.OK;
 
-               if (!File.Exists (src)) {
-                       data.result = UserControlResult.FileNotFound;
-                       return data;
-               }
-
-               UserControlCompiler compiler = new UserControlCompiler (new UserControlParser (src));
+               UserControlCompiler compiler = new UserControlCompiler (new UserControlParser (src, context));
                Type t = compiler.GetCompiledType ();
                if (t == null) {
                        data.result = UserControlResult.CompilationFailed;
index e864b2252e608fc11411f881057b23a9de9516ff..9d7bb34113774fec5bebfba8eba2e80ef31e9615 100644 (file)
@@ -1,3 +1,13 @@
+2002-12-18  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * AspGenerator.cs: now it uses the current HttpContext when creating
+       user controls. TemplateSourceDirectory is no longer a dummy value.
+
+       * GlobalAsaxCompiler.cs:
+       * PageCompiler.cs:
+       * UserControlCompiler.cs: set the context which will be used to locate
+       the files.
+       
 2002-12-13  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * AspGenerator.cs: added support for AutoEventWireup attribute in
index 7425a6c1a6d772e0f0e5c63aafd0a96a1e52379d..718f679ee61a4c20e01e1d85d08e65783f01066d 100644 (file)
@@ -19,6 +19,7 @@ namespace System.Web.Compilation
        {
                string filename;
                string sourceFile;
+               HttpContext context;
 
                private GlobalAsaxCompiler (string filename)
                {
@@ -60,7 +61,7 @@ namespace System.Web.Compilation
                        }
                }
 
-               public static Type CompileApplicationType (string filename)
+               public static Type CompileApplicationType (string filename, HttpContext context)
                {
                        CompilationCacheItem item = CachingCompiler.GetCached (filename);
                        if (item != null && item.Result != null) {
@@ -71,6 +72,7 @@ namespace System.Web.Compilation
                        }
 
                        GlobalAsaxCompiler gac = new GlobalAsaxCompiler (filename);
+                       gac.context = context;
                        return gac.GetCompiledType ();
                }
 
@@ -80,6 +82,7 @@ namespace System.Web.Compilation
                        AspParser parser = new AspParser (filename, input);
                        parser.Parse ();
                        AspGenerator generator = new AspGenerator (filename, parser.Elements);
+                       generator.Context = context;
                        generator.BaseType = typeof (HttpApplication).ToString ();
                        generator.ProcessElements ();
                        string generated = generator.GetCode ().ReadToEnd ();
index b28ad3462b76158625b512e77ec1a0aafececeae..2fe1261e948455d397c22a3d6f4a5d2d317e4c70 100644 (file)
@@ -85,6 +85,7 @@ namespace System.Web.Compilation
                        AspParser parser = new AspParser (inputFile, input);
                        parser.Parse ();
                        AspGenerator generator = new AspGenerator (inputFile, parser.Elements);
+                       generator.Context = pageParser.Context;
                        generator.BaseType = pageParser.BaseType.ToString ();
                        generator.ProcessElements ();
                        pageParser.Text = generator.GetCode ().ReadToEnd ();
index 9c036a20f5dae158bc57c92c6bde6617c594949f..c31d9fdf768e74245704fe9b4fc11ba93238f128 100644 (file)
@@ -99,6 +99,7 @@ namespace System.Web.Compilation
                        AspParser parser = new AspParser (inputFile, input);
                        parser.Parse ();
                        AspGenerator generator = new AspGenerator (inputFile, parser.Elements);
+                       generator.Context = userControlParser.Context;
                        generator.BaseType = userControlParser.BaseType.ToString ();
                        generator.ProcessElements ();
                        userControlParser.Text = generator.GetCode ().ReadToEnd ();
index 379b5f6c3f56671cc954afd1f66b662e930c2382..52eedc64f854e35514bd0799db099871950a6139 100755 (executable)
@@ -7,8 +7,10 @@
 //
 // (C) 2002 Ximian, Inc. (http://www.ximian.com)
 //
+
 using System.IO;
 using System.Web;
+using System.Web.Util;
 
 namespace System.Web.UI
 {
@@ -26,7 +28,10 @@ namespace System.Web.UI
 
                internal string MapPath (string path, bool allowCrossAppMapping)
                {
-                       return context.Request.MapPath (path, baseVDir, allowCrossAppMapping);
+                       if (context == null)
+                               throw new HttpException ("context is null!!");
+
+                       return context.Request.MapPath (path, BaseVirtualDir, allowCrossAppMapping);
                }
 
                internal string PhysicalPath (string path)
@@ -34,7 +39,7 @@ namespace System.Web.UI
                        if (Path.DirectorySeparatorChar != '/')
                                path = path.Replace ('/', '\\');
                                
-                       return Path.GetFullPath (Path.Combine (baseVDir, path));
+                       return Path.GetFullPath (Path.Combine (BaseVirtualDir, path));
                }
 
                internal HttpContext Context
@@ -42,13 +47,16 @@ namespace System.Web.UI
                        get {
                                return context;
                        }
+                       set {
+                               context = value;
+                       }
                }
 
                internal string BaseDir
                {
                        get {
                                if (baseDir == null)
-                                       baseDir = MapPath (baseVDir, false);
+                                       baseDir = MapPath (BaseVirtualDir, false);
 
                                return baseDir;
                        }
@@ -57,6 +65,9 @@ namespace System.Web.UI
                internal string BaseVirtualDir
                {
                        get {
+                               if (baseVDir == null)
+                                       baseVDir = UrlUtils.GetDirectory (context.Request.FilePath);
+
                                return baseVDir;
                        }
                }
index be53a462820e21b3b14b4a8989eb97dac34604de..c497035cabea5354e0aca752bccb1430edb208f7 100644 (file)
@@ -1,3 +1,12 @@
+2002-12-18  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * BaseParser.cs: use MapPath and context to locate files.
+       * Control.cs: implemented MapPathSecure.
+       * TemplateControl.cs: use UrlUtils to generate the path.
+       * TemplateControlParser.cs: use the context and MapPath.
+       * UserControl.cs: implemented MapPath.
+       * UserControlParser.cs: added context parameter to constructor.
+
 2002-12-17  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * Control.cs: implemented MapPathSecure.
index 6eb9f72cb57ad6d0874f91bcb5166d23380008f2..9d58572f7d630f725b5c2fc7279d5281648207ca 100644 (file)
@@ -423,7 +423,8 @@ namespace System.Web.UI
                [MonoTODO("Secure?")]\r
                 protected string MapPathSecure(string virtualPath)\r
                 {\r
-                       return Context.Request.MapPath (virtualPath);\r
+                       string combined = UrlUtils.Combine (TemplateSourceDirectory, virtualPath);\r
+                       return Context.Request.MapPath (combined);\r
                 }\r
 \r
                 protected virtual bool OnBubbleEvent(object source, EventArgs args) //DIT\r
index 8063aad5b8651b43f69ec5f65c7e91b3d255b9ed..c5498d5d977a715e79c552a8ac40d9c6b6b2c4fe 100755 (executable)
@@ -112,12 +112,8 @@ namespace System.Web.UI {
                        if (virtualPath == null)
                                throw new ArgumentNullException ("virtualPath");
 
-                       if (virtualPath [0] == '/')
-                               throw new ArgumentException ("Path cannot be rooted", "virtualPath");
-
-                       virtualPath = PathUtil.Combine (TemplateSourceDirectory, virtualPath);
-
-                       return UserControlCompiler.CompileUserControlType (new UserControlParser (virtualPath));
+                       string vpath = UrlUtils.Combine (TemplateSourceDirectory, virtualPath);
+                       return UserControlCompiler.CompileUserControlType (new UserControlParser (vpath, Context));
                }
 
                public Control LoadControl (string virtualPath)
index 8b459009b55d5d048cfcbd74fca851f60cbde490..33f05b48bb5e5cfaee6566ca82deadaa19a5d14a 100644 (file)
@@ -10,6 +10,7 @@ using System;
 using System.Collections;
 using System.IO;
 using System.Web.Compilation;
+using System.Web.Util;
 
 namespace System.Web.UI
 {
@@ -17,7 +18,8 @@ namespace System.Web.UI
        {
                internal object GetCompiledInstance (string virtualPath, string inputFile, HttpContext context)
                {
-                       InputFile = inputFile;
+                       Context = context;
+                       InputFile = MapPath (virtualPath);
                        Type type = CompileIntoType ();
                        if (type == null)
                                return null;
index 197eef4bc0fc0ab20a3b204fe30b6831a8909907..d223b0893e3a4cdd179ad86473657d204fb274d9 100644 (file)
@@ -135,10 +135,9 @@ namespace System.Web.UI
                        FrameworkInitialize ();
                }
 
-               [MonoTODO]
                public string MapPath (string virtualPath)
                {
-                       throw new NotImplementedException ();
+                       return Request.MapPath (virtualPath, TemplateSourceDirectory, true);
                }
 
                protected override void LoadViewState (object savedState)
index b1d5ca6fe8f5c7791c39ffbc4d4ec40220406955..16253a6533db941f2f886ff84517f5eda294d3c8 100644 (file)
@@ -14,14 +14,15 @@ namespace System.Web.UI
 {
        public sealed class UserControlParser : TemplateControlParser
        {
-               internal UserControlParser (string inputFile)
+               internal UserControlParser (string inputFile, HttpContext context)
                {
-                       InputFile = inputFile;
+                       Context = context;
+                       InputFile = context.Request.MapPath (inputFile);
                }
                
                public static Type GetCompiledType (string virtualPath, string inputFile, HttpContext context)
                {
-                       UserControlParser ucp = new UserControlParser (inputFile);
+                       UserControlParser ucp = new UserControlParser (inputFile, context);
                        Type t = ucp.CompileIntoType ();
                        return t;
                }
index f1f16c9ac53fe9a2fe20291e448dcc8c52260e6d..dccc3905d58d7b08503aca46f9e27f317de0b82f 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-18  Gonzalo Paniagua Javier <gonzalo@ximian.com>\r
+\r
+       * PathUtil.cs: removed.\r
+       * UrlUtils.cs: fixed Combine to handle '~'.\r
+\r
 2002-12-12  Gonzalo Paniagua Javier <gonzalo@ximian.com>\r
 \r
        * PathUtil.cs: some path handling methods that are not available in\r
diff --git a/mcs/class/System.Web/System.Web.Util/PathUtil.cs b/mcs/class/System.Web/System.Web.Util/PathUtil.cs
deleted file mode 100644 (file)
index a2bd96c..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// System.Web.Util.PathUtil
-//
-// Authors:
-//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
-//
-// (C) 2002 Ximian, Inc (http://www.ximian.com)
-//
-
-using System;
-using System.Collections;
-using System.IO;
-using System.Reflection;
-
-namespace System.Web.Util
-{
-       internal class PathUtil
-       {
-               static string appbase;
-               static char [] separators;
-
-               static PathUtil ()
-               {
-                       // This hack is a workaround until AppDomainVirtualPath works... Gotta investigate it.
-                       Assembly entry = Assembly.GetEntryAssembly ();
-                       appbase = Path.GetDirectoryName (entry.Location);
-                       //
-
-                       if (Path.DirectorySeparatorChar != Path.AltDirectorySeparatorChar)
-                               separators = new char [] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar};
-                       else
-                               separators = new char [] {Path.DirectorySeparatorChar};
-               }
-               
-               static string MakeAbsolute (string abspath)
-               {
-                       string [] parts = abspath.Split (separators);
-                       ArrayList valid = new ArrayList ();
-
-                       int len = parts.Length;
-                       bool hasDots = false;
-                       for (int i = 0; i < len; i++) {
-                               if (parts [i] == ".") {
-                                       hasDots = true;
-                                       continue;
-                               }
-
-                               if (parts [i] == "..") {
-                                       hasDots = true;
-                                       if (valid.Count > 0)
-                                               valid.RemoveAt (valid.Count - 1);
-                                       continue;
-                               }
-
-                               valid.Add (parts [i]);
-                       }
-
-                       if (!hasDots)
-                               return abspath;
-
-                       parts = (String []) valid.ToArray (typeof (string));
-                       string result = String.Join (new String (Path.DirectorySeparatorChar, 1), parts);
-                       if (!Path.IsPathRooted (result))
-                               return Path.DirectorySeparatorChar + result;
-
-                       return result;
-               }
-
-               static public string Combine (string basepath, string relative)
-               {
-                       if (relative == null || relative.Length == 0)
-                               throw new ArgumentException ("empty or null", "relative");
-
-                       char first = relative [0];
-                       if (first == '/' || first == '\\' || Path.IsPathRooted (relative))
-                               throw new ArgumentException ("'relative' is rooted", "relative");
-
-                       if (first == '~' && relative.Length > 1 && Array.IndexOf (separators, relative [1]) != -1)
-                               return Path.Combine (appbase, relative.Substring (2));
-
-                       if (basepath == null)
-                               basepath = appbase;
-
-                       return MakeAbsolute (Path.Combine (basepath, relative));
-               }
-       }
-}
-
index 2573ec54da5e079d28da0996776b14d3e7fec2a1..09ae37afd4a94580279966a7e680606c8214307c 100644 (file)
@@ -96,34 +96,35 @@ namespace System.Web.Util
                \r
                public static void FailIfPhysicalPath(string path)\r
                {\r
-                       if(path!= null && path.Length > 0)\r
+                       if(path!= null && path.Length > 1)\r
                        {\r
-                               if(path[0]==':' || path.StartsWith(@"\\"))\r
+                               if(path[1]==':' || path.StartsWith(@"\\"))\r
                                        throw new HttpException(HttpRuntime.FormatResourceString("Physical_path_not_allowed", path));\r
                        }\r
                }\r
                \r
-               public static string Combine(string basePath, string relPath)\r
+               public static string Combine (string basePath, string relPath)\r
                {\r
-                       FailIfPhysicalPath(relPath);\r
-                       if(IsRootUrl(relPath))\r
-                       {\r
-                               if(relPath != null && relPath.Length > 0)\r
-                               {\r
-                                       return Reduce(relPath);\r
-                               }\r
+                       FailIfPhysicalPath (relPath);\r
+                       if (IsRootUrl (relPath)) {\r
+                               if (relPath != null && relPath.Length > 0)\r
+                                       return Reduce (relPath);\r
+\r
                                return String.Empty;\r
                        }\r
-                       if(relPath.Length < 3 || relPath[0]!='~' || (relPath[0]!='/' && relPath[0]!='\\'))\r
-                       {\r
-                               if(basePath==null || basePath.Length==1 || basePath[0]=='/')\r
+\r
+                       if (relPath.Length < 3 || relPath [0] != '~' || relPath [0] == '/' || relPath [0] == '\\') {\r
+                               if (basePath == null || basePath.Length == 1 || basePath [0] == '/')\r
                                        basePath = String.Empty;\r
-                               return Reduce(basePath + "/" + relPath);\r
+\r
+                               return Reduce (basePath + "/" + relPath);\r
                        }\r
+\r
                        string vPath = HttpRuntime.AppDomainAppVirtualPath;\r
-                       if(vPath.Length <= 1)\r
+                       if (vPath.Length <= 1)\r
                                vPath = String.Empty;\r
-                       return Reduce(vPath + "/" + relPath.Substring(2));\r
+\r
+                       return Reduce (vPath + "/" + relPath.Substring (2));\r
                }\r
                \r
                public static bool IsValidProtocol(string protocol)\r
index 2b03cfb6487e749cc48f03ed6e16b412a38a32fb..1946319e1f1fed131f60bfba5d1dc1ed649b2961 100644 (file)
@@ -1,3 +1,15 @@
+2002-12-18  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * HttpApplicationFactory.cs: add the context as parameter when building
+       the application Type.
+       
+       * HttpCookie.cs: new internal constructor.
+       * HttpCookieCollection.cs: new internal method to make a cookie expire.
+
+       * HttpRequest.cs: MapPath fixes.
+       * HttpResponse.cs: implemented ApplyAppPathModifier.
+       * HttpRuntime.cs: fixed typo in AppDomainAppVirtualPath.
+
 2002-12-17  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * HttpContext.cs: hack to create a default user when there's no one.
index 3a95fdb39ea3216db7f46ccfa1215ed24e17f39d..dc9baddc366c61c2003ad6f77ab0ccd875605a97 100644 (file)
@@ -78,7 +78,7 @@ namespace System.Web {
                        if (File.Exists(_appFilename)) {\r
                                // Setup filemonitor for all filedepend also. CacheDependency?\r
 \r
-                               _appType = GlobalAsaxCompiler.CompileApplicationType (_appFilename);\r
+                               _appType = GlobalAsaxCompiler.CompileApplicationType (_appFilename, context);\r
                                if (_appType == null)\r
                                        throw new ApplicationException ("Error compiling application file (global.asax).");\r
                        } else {\r
index 115c27e64c7ff5e01685aac7ac8b5b24976101b3..880acd27777c22a752ae8be86865fbdc03867c20 100644 (file)
@@ -41,6 +41,15 @@ namespace System.Web
                        _Path = "/";
                }
 
+               internal HttpCookie (string name, string value, string path, DateTime expires)
+               {
+                       _Name = name;
+                       _Value = value;
+                       _Path = path;
+                       if (expires != DateTime.MinValue)
+                               Expires = expires;
+               }
+               
                internal HttpResponseHeader GetCookieHeader ()
                {
                        StringBuilder oSetCookie = new StringBuilder ();
index 7ab1cde8a81660c6a0a336e835b0b7aeaf65a459..e9872411813e170e2c7cbe6af5d892a0ca115413 100644 (file)
@@ -134,6 +134,14 @@ namespace System.Web
                        if (null != _Response)
                                _Response.ChangedCookieColl();
                }
+
+               internal void MakeCookieExpire (string name, string path)
+               {
+                       DateTime expirationTime = new DateTime (1999, 10, 12); // This is the date MS sends!
+                       HttpCookie willExpire = new HttpCookie (name, String.Empty, path, expirationTime);
+                       Remove (name);
+                       Add (willExpire);
+               }
        }
 }
 
index 1e2404f3e5a9b95f22b4acc351f7848626b10a21..32f8edeccf382ec59d6733c84fa57858c675eea3 100644 (file)
@@ -61,6 +61,7 @@ namespace System.Web {
                private HttpBrowserCapabilities _browser;\r
 \r
                private HttpCookieCollection cookies;\r
+               private bool rewritten;\r
 \r
                public HttpRequest(string Filename, string Url, string Querystring) {\r
                        _iContentLength = -1;\r
@@ -697,11 +698,12 @@ namespace System.Web {
 \r
                public string PhysicalPath {\r
                        get {\r
-                               if (null != _WorkerRequest) {\r
-                                       _sPathTranslated = _WorkerRequest.GetFilePathTranslated();\r
-                                       if (null == _sPathTranslated) {\r
-                                               _sPathTranslated = _WorkerRequest.MapPath(FilePath);\r
-                                       }\r
+                               if (_sPathTranslated == null && _WorkerRequest != null) {\r
+                                       if (rewritten)\r
+                                               _sPathTranslated = _WorkerRequest.GetFilePathTranslated ();\r
+\r
+                                       if (null == _sPathTranslated)\r
+                                               _sPathTranslated = _WorkerRequest.MapPath (FilePath);\r
                                }\r
 \r
                                return _sPathTranslated;\r
@@ -876,6 +878,21 @@ namespace System.Web {
                        }\r
                }\r
 \r
+               internal string RootVirtualDir {\r
+                       get {\r
+                               if (_sRequestRootVirtualDir == null) {\r
+                                       _sRequestRootVirtualDir = FilePath;\r
+                                       int pos = _sRequestRootVirtualDir.LastIndexOf ('/');\r
+                                       if (pos == -1 || pos == 0)\r
+                                               _sRequestRootVirtualDir = "/";\r
+                                       else\r
+                                               _sRequestRootVirtualDir = _sRequestRootVirtualDir.Substring (0, pos);\r
+                               }\r
+\r
+                               return _sRequestRootVirtualDir;\r
+                       }\r
+               }\r
+               \r
                public byte [] BinaryRead(int count) {\r
                        int iSize = TotalBytes;\r
                        if (iSize == 0) {\r
@@ -927,29 +944,34 @@ namespace System.Web {
                        return arrRet;\r
                }\r
 \r
-               public string MapPath(string VirtualPath)\r
+               public string MapPath (string VirtualPath)\r
                {\r
-                       if (_sRequestRootVirtualDir == null) {\r
-                               _sRequestRootVirtualDir = FilePath;\r
-                               int pos = _sRequestRootVirtualDir.LastIndexOf ('/');\r
-                               if (pos == -1 || pos == 0)\r
-                                       _sRequestRootVirtualDir = "/";\r
-                               else\r
-                                       _sRequestRootVirtualDir = _sRequestRootVirtualDir.Substring (0, pos);\r
-                       }\r
-                       return MapPath (VirtualPath, _sRequestRootVirtualDir, true);\r
+                       return MapPath (VirtualPath, RootVirtualDir, true);\r
                }\r
 \r
-               [MonoTODO]\r
-               public string MapPath(string virtualPath, string baseVirtualDir, bool allowCrossAppMapping)\r
+               [MonoTODO("allowCrossAppMapping?")]\r
+               public string MapPath (string virtualPath, string baseVirtualDir, bool allowCrossAppMapping)\r
                {\r
                        if (_WorkerRequest == null)\r
                                throw new HttpException ("No HttpWorkerRequest!!!");\r
 \r
                        if (virtualPath == null || virtualPath.Length == 0)\r
                                virtualPath = ".";\r
+                       else\r
+                               virtualPath = virtualPath.Trim ();\r
+\r
+                       if (System.IO.Path.DirectorySeparatorChar != '/')\r
+                               virtualPath = virtualPath.Replace (System.IO.Path.DirectorySeparatorChar, '/');\r
+\r
+                       if (UrlUtils.IsRooted (virtualPath)) {\r
+                               virtualPath = UrlUtils.Reduce (virtualPath);\r
+                       } else {\r
+                               if (baseVirtualDir == null)\r
+                                       virtualPath = UrlUtils.Combine (RootVirtualDir, virtualPath);\r
+                               else\r
+                                       virtualPath = UrlUtils.Combine (baseVirtualDir, virtualPath);\r
+                       }\r
 \r
-                       virtualPath = System.IO.Path.Combine (baseVirtualDir, virtualPath);\r
                        return _WorkerRequest.MapPath (virtualPath);\r
                }\r
 \r
index 2cd9357274d63fb1aa46809203e22f895cd10b6e..9a3f18391c69aa2a6c1a6a0d89a98d7c780b8aac 100644 (file)
@@ -176,8 +176,9 @@ namespace System.Web
 
                        if (_Cookies != null) {
                                int length = _Cookies.Count;
-                               for (int i = 0; i < length; i++)
+                               for (int i = 0; i < length; i++) {
                                        oHeaders.Add (_Cookies.Get (i).GetCookieHeader ());
+                               }
                        }
 
                        return oHeaders;
@@ -269,10 +270,18 @@ namespace System.Web
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO()]
                public string ApplyAppPathModifier (string virtualPath)
                {
-                       throw new NotImplementedException ();
+                       if (virtualPath == null)
+                               return null;
+
+                       if (UrlUtils.IsRelativeUrl (virtualPath)) {
+                               virtualPath = UrlUtils.Combine (_Context.Request.RootVirtualDir, virtualPath);
+                       } else if (UrlUtils.IsRooted (virtualPath)) {
+                               virtualPath = UrlUtils.Reduce (virtualPath);
+                       }
+
+                       return virtualPath;
                }
 
                public bool Buffer
@@ -751,6 +760,7 @@ namespace System.Web
 
                        Clear ();
 
+                       url = ApplyAppPathModifier (url);
                        StatusCode = 302;
                        AppendHeader (HttpWorkerRequest.HeaderLocation, url);
 
index 093c08241b8e35fad36fa296a3376c5f7f57265b..5c798a03f18c567191b4c3ebea1959f27f1aba5f 100644 (file)
@@ -266,7 +266,7 @@ namespace System.Web {
                public static string AppDomainAppVirtualPath {
                        get {
                                if (appDomainAppVirtualPath == null)
-                                       appDomainAppPath = (string) AppDomain.CurrentDomain.GetData (".appVPath");
+                                       appDomainAppVirtualPath = (string) AppDomain.CurrentDomain.GetData (".appVPath");
 
                                return appDomainAppVirtualPath;
                        }
index 03516737a2b01536cbba9d105e28d91400d960a9..0fb7ac8e943059265d8c101490d9d0d60f62495c 100755 (executable)
@@ -324,7 +324,6 @@ System.Web.Util/FileChangesMonitor.cs
 System.Web.Util/FilePathParser.cs
 System.Web.Util/IISVersionInfo.cs
 System.Web.Util/NativeFileChangeEventHandler.cs
-System.Web.Util/PathUtil.cs
 System.Web.Util/UrlUtils.cs
 System.Web.Util/WebEncoding.cs
 System.Web.Util/WebEqualComparer.cs