2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.Web / System.Web / HttpResponse.cs
index 586652bf37a0db68abc93ac9db9bfe0f04ad8a67..734c2018db7a4cf2a6ec79ff1dfa8c58a900aabf 100644 (file)
@@ -7,6 +7,27 @@
 //
 // (c) 2002 Ximian, Inc. (http://www.ximian.com)
 //
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
 using System;
 using System.Collections;
 using System.Globalization;
@@ -169,7 +190,7 @@ namespace System.Web
                        CultureInfo oSavedInfo = Thread.CurrentThread.CurrentCulture;
                        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
 
-                       string date = DateTime.Now.ToUniversalTime ().ToString ("ddd, d MMM yyyy HH:mm:ss ");
+                       string date = DateTime.UtcNow.ToString ("ddd, d MMM yyyy HH:mm:ss ");
                        HttpResponseHeader date_header = new HttpResponseHeader ("Date", date + "GMT");
                        oHeaders.Add (date_header);
                        
@@ -335,8 +356,15 @@ namespace System.Web
                                virtualPath = UrlUtils.Reduce (virtualPath);
                        }
 
-                       if (app_path_mod != null && virtualPath.IndexOf (app_path_mod) > 0)
-                               virtualPath = UrlUtils.Combine (app_path_mod, virtualPath);
+                       if (app_path_mod != null && virtualPath.IndexOf (app_path_mod) < 0) {
+                               string rvd = _Context.Request.RootVirtualDir;
+                               string basevd = rvd.Replace (app_path_mod, "");
+
+                               if (!virtualPath.StartsWith (basevd))
+                                       return virtualPath;
+
+                               virtualPath = UrlUtils.Combine (rvd, virtualPath.Substring (basevd.Length));
+                       }
 
                        return virtualPath;
                }
@@ -475,10 +503,10 @@ namespace System.Web
                        }
 
                        set {
-                               if (!_expiresInMinutesSet || (value < _expiresInMinutes))\r
-                               {\r
-                                       _expiresInMinutes = value;\r
-                                       Cache.SetExpires(_Context.Timestamp.Add(new TimeSpan(0, _expiresInMinutes, 0)));\r
+                               if (!_expiresInMinutesSet || (value < _expiresInMinutes))
+                               {
+                                       _expiresInMinutes = value;
+                                       Cache.SetExpires(_Context.Timestamp.Add(new TimeSpan(0, _expiresInMinutes, 0)));
                                }
                                _expiresInMinutesSet = true;
                        }
@@ -491,10 +519,10 @@ namespace System.Web
                        }
 
                        set {
-                               if (!_expiresAbsoluteSet || value.CompareTo(_expiresAbsolute)<0)\r
-                               {\r
-                                       _expiresAbsolute = value;\r
-                                       Cache.SetExpires(_expiresAbsolute); \r
+                               if (!_expiresAbsoluteSet || value.CompareTo(_expiresAbsolute)<0)
+                               {
+                                       _expiresAbsolute = value;
+                                       Cache.SetExpires(_expiresAbsolute); 
                                }
                                _expiresAbsoluteSet = true;
                        }
@@ -597,9 +625,6 @@ namespace System.Web
                        }
                        
                        set {
-                               if (_bHeadersSent)
-                                       throw new HttpException ("Headers has been sent to the client");
-
                                _bSuppressContent = true;
                        }
                }
@@ -692,6 +717,11 @@ namespace System.Web
                        Clear();
                }
 
+               internal void SetHeadersSent (bool val)
+               {
+                       _bHeadersSent = val;
+               }
+               
                public void ClearHeaders ()
                {
                        if (_bHeadersSent)
@@ -825,6 +855,9 @@ namespace System.Web
                                if (!_bSuppressContent && Request.HttpMethod == "HEAD")
                                        _bSuppressContent = true;
 
+                               if (_bSuppressContent)
+                                       _Writer.Clear ();
+
                                if (!_bSuppressContent) {
                                        _bClientDisconnected = false;
                                        if (_bChunked) {