From d0605fd04e8834bf8d1d085a4227eb03ac47e444 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Wed, 20 Aug 2008 12:46:13 +0000 Subject: [PATCH] Optimization of the bug #418620 fix, by Juraj Skripsky , thanks! svn path=/trunk/mcs/; revision=111107 --- .../System.Web/System.Web/HttpResponseHeader.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mcs/class/System.Web/System.Web/HttpResponseHeader.cs b/mcs/class/System.Web/System.Web/HttpResponseHeader.cs index 352b70d7214..27fd8d9a8ee 100644 --- a/mcs/class/System.Web/System.Web/HttpResponseHeader.cs +++ b/mcs/class/System.Web/System.Web/HttpResponseHeader.cs @@ -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; -- 2.25.1