X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Web%2FSystem.Web%2FHttpResponseHeader.cs;h=432129dcae2392ad633ccb2d6e91f3a68d3311ab;hb=f0c4bb76e4ecda59938fa6d2fde07b84e322b14e;hp=49b356c2fefa7c70a706990519b74cb9fddbd7d1;hpb=e79159ff2d1ddac821408a4d730f81db2a4692cb;p=mono.git diff --git a/mcs/class/System.Web/System.Web/HttpResponseHeader.cs b/mcs/class/System.Web/System.Web/HttpResponseHeader.cs index 49b356c2fef..432129dcae2 100644 --- a/mcs/class/System.Web/System.Web/HttpResponseHeader.cs +++ b/mcs/class/System.Web/System.Web/HttpResponseHeader.cs @@ -1,53 +1,117 @@ -// -// System.Web.HttpResponseHeader -// -// Author: -// Patrik Torstensson (Patrik.Torstensson@labs2.com) -// -using System; - -namespace System.Web { - public class HttpResponseHeader { - private string _sHeader; - private string _sValue; - private int _iKnowHeaderId; - - public HttpResponseHeader(int KnowHeaderId, string value) { - _iKnowHeaderId = KnowHeaderId; - _sValue = value; - } - - public HttpResponseHeader(string header, string value) { - _sHeader = header; - _sValue = value; - } - - public string Name { - get { - if (null == _sHeader) { - return HttpWorkerRequest.GetKnownResponseHeaderName(_iKnowHeaderId); - } - - return _sHeader; - } - } - - public string Value { - get { - return _sValue; - } - } - - override public string ToString() { - return Name + ": " + Value; - } - - internal void SendContent(HttpWorkerRequest WorkerRequest) { - if (null != _sHeader) { - WorkerRequest.SendUnknownResponseHeader(_sHeader, _sValue); - } else { - WorkerRequest.SendKnownResponseHeader(_iKnowHeaderId, _sValue); - } - } - } -} +// +// System.Web.HttpResponseHeader.cs +// +// Author: +// Chris Toshok (toshok@novell.com) +// + +// +// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.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.Collections; +using System.Text; +using System.Web.Configuration; +using System.Web.Util; + +namespace System.Web +{ + abstract class BaseResponseHeader + { + string headerValue; + + public string Value { + get { return headerValue; } + set { + string hname, hvalue; +#if NET_4_0 + HttpEncoder.Current.HeaderNameValueEncode (null, value, out hname, out hvalue); +#else + HttpEncoder.HeaderNameValueEncode (null, value, out hname, out hvalue); +#endif + headerValue = hvalue; + } + } + + static bool headerCheckingEnabled; + + static BaseResponseHeader () + { + HttpRuntimeSection section = WebConfigurationManager.GetWebApplicationSection ("system.web/httpRuntime") as HttpRuntimeSection; + headerCheckingEnabled = section == null || section.EnableHeaderChecking; + } + + + internal BaseResponseHeader (string val) + { + Value = val; + } + + internal abstract void SendContent (HttpWorkerRequest wr); + } + + internal sealed class KnownResponseHeader : BaseResponseHeader + { + public int ID; + + internal KnownResponseHeader (int ID, string val) : base (val) + { + this.ID = ID; + } + + internal override void SendContent (HttpWorkerRequest wr) + { + wr.SendKnownResponseHeader (ID, Value); + } + } + + internal sealed class UnknownResponseHeader : BaseResponseHeader + { + string headerName; + + public string Name { + get { return headerName; } + set { + string hname, hvalue; +#if NET_4_0 + HttpEncoder.Current.HeaderNameValueEncode (value, null, out hname, out hvalue); +#else + HttpEncoder.HeaderNameValueEncode (value, null, out hname, out hvalue); +#endif + headerName = hname; + } + } + + + public UnknownResponseHeader (string name, string val) : base (val) + { + Name = name; + } + + internal override void SendContent (HttpWorkerRequest wr) + { + wr.SendUnknownResponseHeader (Name, Value); + } + + } +} +