2009-06-04 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Thu, 4 Jun 2009 18:47:55 +0000 (18:47 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Thu, 4 Jun 2009 18:47:55 +0000 (18:47 -0000)
* HttpResponse.cs: version header configuration is read lazily
now.

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

mcs/class/System.Web/System.Web/ChangeLog
mcs/class/System.Web/System.Web/HttpResponse.cs

index 0a54c0f80004dc82a8e2a3db3015822b850f6cff..dc2076f1449a6ea950b253d2a4b049f4010f6ce7 100644 (file)
@@ -1,5 +1,8 @@
 2009-06-04  Marek Habersack  <mhabersack@novell.com>
 
+       * HttpResponse.cs: version header configuration is read lazily
+       now.
+
        * HttpException.cs: do not show version info if custom errors are
        in effect. Fixes bug #509092
 
index 5895e7044a6199aa475e505289e298f6f96f27ea..7ed591b59ee7c4bd7f11d7f83c6a41ab26fa822c 100644 (file)
@@ -68,8 +68,8 @@ namespace System.Web {
                CachedRawResponse cached_response;
                string user_cache_control = "private";
                string redirect_location;
-               
-               static string version_header;
+               string version_header;
+               bool version_header_checked;
                
                //
                // Negative Content-Length means we auto-compute the size of content-length
@@ -105,17 +105,6 @@ namespace System.Web {
                Encoding headerEncoding;
 #endif
 
-               static HttpResponse ()
-               {
-#if NET_2_0
-                       HttpRuntimeSection config = WebConfigurationManager.GetWebApplicationSection ("system.web/httpRuntime") as HttpRuntimeSection;
-#else
-                       HttpRuntimeConfig config = HttpContext.GetAppConfig ("system.web/httpRuntime") as HttpRuntimeConfig;
-#endif
-                       if (config != null && config.EnableVersionHeader)
-                               version_header = Environment.Version.ToString (3);
-               }
-               
                internal HttpResponse ()
                {
                        output_stream = new HttpResponseStream (this);
@@ -144,6 +133,23 @@ namespace System.Web {
                        return prev;
                }
 
+               internal string VersionHeader {
+                       get {
+                               if (!version_header_checked && version_header == null) {
+                                       version_header_checked = true;
+#if NET_2_0
+                                       HttpRuntimeSection config = WebConfigurationManager.GetWebApplicationSection ("system.web/httpRuntime") as HttpRuntimeSection;
+#else
+                                       HttpRuntimeConfig config = HttpContext.GetAppConfig ("system.web/httpRuntime") as HttpRuntimeConfig;
+#endif
+                                       if (config != null && config.EnableVersionHeader)
+                                               version_header = Environment.Version.ToString (3);
+                               }
+
+                               return version_header;
+                       }
+               }
+               
                internal string[] FileDependencies {
                        get {
                                if (fileDependencies == null || fileDependencies.Count == 0)
@@ -675,8 +681,9 @@ namespace System.Web {
                                write_headers.Add ("Location", redirect_location);
                        
 #if !TARGET_J2EE
-                       if (version_header != null)
-                               write_headers.Add ("X-AspNet-Version", version_header);
+                       string vh = VersionHeader;
+                       if (vh != null)
+                               write_headers.Add ("X-AspNet-Version", vh);
 
                        //
                        // If Content-Length is set.