Optimization of the bug #418620 fix, by Juraj Skripsky <juraj@hotfeet.ch>, thanks!
authorMarek Habersack <grendel@twistedcode.net>
Wed, 20 Aug 2008 12:46:13 +0000 (12:46 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 20 Aug 2008 12:46:13 +0000 (12:46 -0000)
svn path=/trunk/mcs/; revision=111107

mcs/class/System.Web/System.Web/HttpResponseHeader.cs

index 352b70d72146f3d25e9d72d82d3b76d560459db2..27fd8d9a8ee2b113c9b2b5e04e7b8564602c6f7d 100644 (file)
@@ -42,6 +42,15 @@ namespace System.Web {
                        set { headerValue = EncodeHeader (value); }
                }
          
+#if NET_2_0
+               static bool headerCheckingEnabled;
+               
+               static BaseResponseHeader () {
+                       HttpRuntimeSection section = WebConfigurationManager.GetSection ("system.web/httpRuntime") as HttpRuntimeSection;
+                       headerCheckingEnabled = section == null || section.EnableHeaderChecking;
+               }
+#endif
+
                internal BaseResponseHeader (string val)
                {
                        Value = val;
@@ -53,10 +62,7 @@ namespace System.Web {
                        if (String.IsNullOrEmpty (value))
                                return value;
                        
-                       HttpRuntimeSection section = WebConfigurationManager.GetSection ("system.web/httpRuntime") as HttpRuntimeSection;
-                       bool doEncode = section == null || section.EnableHeaderChecking;
-
-                       if (doEncode) {
+                       if (headerCheckingEnabled) {
                                StringBuilder ret = new StringBuilder ();
                                int len = value.Length;