Merge pull request #2098 from evincarofautumn/fix-gchandle-assert
[mono.git] / mcs / class / System.Web / System.Web / StaticFileHandler.cs
index 2ed20085e1aa2fff055b2e66aa30ec42e04542c6..810f24c564439a5a3644839e418d5be541de8632 100644 (file)
@@ -5,6 +5,7 @@
 //     Gonzalo Paniagua Javier (gonzalo@ximian.com)
 //
 // (C) 2002 Ximian, Inc (http://www.ximian.com)
+// (C) 2003-2009 Novell, Inc (http://novell.com)
 //
 
 //
@@ -38,17 +39,9 @@ namespace System.Web
 {
        class StaticFileHandler : IHttpHandler
        {
-               static bool runningWindows = RunningOnWindows ();
-
-               static bool RunningOnWindows ()
-               {
-                       int pid = (int)Environment.OSVersion.Platform;
-                       return (pid != 4 && pid != 128);
-               }
-
                static bool ValidFileName (string fileName)
                {
-                       if (!runningWindows)
+                       if (!RuntimeHelpers.RunningOnWindows)
                                return true;
 
                        if (fileName == null || fileName.Length == 0)
@@ -62,7 +55,6 @@ namespace System.Web
                        HttpRequest request = context.Request;
                        HttpResponse response = context.Response;
 
-#if NET_2_0
                        if (HostingEnvironment.HaveCustomVPP) {
                                VirtualFile vf = null;
                                VirtualPathProvider vpp = HostingEnvironment.VirtualPathProvider;
@@ -75,10 +67,9 @@ namespace System.Web
                                        throw new HttpException (404, "Path '" + vpath + "' was not found.", vpath);
 
                                response.ContentType = MimeTypes.GetMimeType (vpath);
-                               response.TransmitFile (vf);
+                               response.TransmitFile (vf, true);
                                return;
                        }
-#endif
                        
                        string fileName = request.PhysicalPath;
                        FileInfo fi = new FileInfo (fileName);
@@ -95,25 +86,9 @@ namespace System.Web
                                if (strHeader != null) {
                                        DateTime dtIfModifiedSince = DateTime.ParseExact (strHeader, "r", null);
                                        DateTime ftime;
-#if TARGET_JVM
-                                       try 
-                                       {
-                                               ftime = fi.LastWriteTime.ToUniversalTime ();
-                                       } 
-                                       catch (NotSupportedException) 
-                                       {
-                                               // The file is in a WAR, it might be modified with last redeploy.
-                                               try {
-                                                       ftime = (DateTime) AppDomain.CurrentDomain.GetData (".appStartTime");
-                                               }
-                                               catch {
-                                                       ftime = DateTime.MaxValue;
-                                               }
-                                       }
-#else
                                        ftime = fi.LastWriteTime.ToUniversalTime ();
-#endif
                                        if (ftime <= dtIfModifiedSince) {
+                                               response.ContentType = MimeTypes.GetMimeType (fileName);
                                                response.StatusCode = 304;
                                                return;
                                        }