HttpResponseHeader.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / HttpResponseHeader.cs / 1305376 / HttpResponseHeader.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

/* 
 * Single http header representation 
 *
 * Copyright (c) 1998 Microsoft Corporation 
 */

namespace System.Web {
    using System; 
    using System.Web.Util;
 
    /* 
     * Response header (either known or unknown)
     */ 
    [Serializable]
    internal class HttpResponseHeader {

        private String _unknownHeader; 
        private int _knownHeaderIndex;
        private String _value; 
 
        internal HttpResponseHeader(int knownHeaderIndex, String value)
            : this(knownHeaderIndex, value, HttpRuntime.EnableHeaderChecking) { 
        }

        internal HttpResponseHeader(int knownHeaderIndex, string value, bool enableHeaderChecking) {
            _unknownHeader = null; 
            _knownHeaderIndex = knownHeaderIndex;
 
            // encode header value if 
            if (enableHeaderChecking) {
                string encodedName; // unused 
                HttpEncoder.Current.HeaderNameValueEncode(Name, value, out encodedName, out _value);
            }
            else {
                _value = value; 
            }
        } 
 
        internal HttpResponseHeader(String unknownHeader, String value)
            : this(unknownHeader, value, HttpRuntime.EnableHeaderChecking) { 
        }

        internal HttpResponseHeader(string unknownHeader, string value, bool enableHeaderChecking) {
            if (enableHeaderChecking) { 
                HttpEncoder.Current.HeaderNameValueEncode(unknownHeader, value, out _unknownHeader, out _value);
                _knownHeaderIndex = HttpWorkerRequest.GetKnownResponseHeaderIndex(_unknownHeader); 
            } 
            else {
                _unknownHeader = unknownHeader; 
                _knownHeaderIndex = HttpWorkerRequest.GetKnownResponseHeaderIndex(_unknownHeader);
                _value = value;
            }
        } 

        internal String Name { 
            get { 
                if (_unknownHeader != null)
                    return _unknownHeader; 
                else
                    return HttpWorkerRequest.GetKnownResponseHeaderName(_knownHeaderIndex);
            }
        } 

        internal String Value { 
            get { return _value; } 
        }
 
        internal void Send(HttpWorkerRequest wr) {
            if (_knownHeaderIndex >= 0)
                wr.SendKnownResponseHeader(_knownHeaderIndex, _value);
            else 
                wr.SendUnknownResponseHeader(_unknownHeader, _value);
        } 
 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

/* 
 * Single http header representation 
 *
 * Copyright (c) 1998 Microsoft Corporation 
 */

namespace System.Web {
    using System; 
    using System.Web.Util;
 
    /* 
     * Response header (either known or unknown)
     */ 
    [Serializable]
    internal class HttpResponseHeader {

        private String _unknownHeader; 
        private int _knownHeaderIndex;
        private String _value; 
 
        internal HttpResponseHeader(int knownHeaderIndex, String value)
            : this(knownHeaderIndex, value, HttpRuntime.EnableHeaderChecking) { 
        }

        internal HttpResponseHeader(int knownHeaderIndex, string value, bool enableHeaderChecking) {
            _unknownHeader = null; 
            _knownHeaderIndex = knownHeaderIndex;
 
            // encode header value if 
            if (enableHeaderChecking) {
                string encodedName; // unused 
                HttpEncoder.Current.HeaderNameValueEncode(Name, value, out encodedName, out _value);
            }
            else {
                _value = value; 
            }
        } 
 
        internal HttpResponseHeader(String unknownHeader, String value)
            : this(unknownHeader, value, HttpRuntime.EnableHeaderChecking) { 
        }

        internal HttpResponseHeader(string unknownHeader, string value, bool enableHeaderChecking) {
            if (enableHeaderChecking) { 
                HttpEncoder.Current.HeaderNameValueEncode(unknownHeader, value, out _unknownHeader, out _value);
                _knownHeaderIndex = HttpWorkerRequest.GetKnownResponseHeaderIndex(_unknownHeader); 
            } 
            else {
                _unknownHeader = unknownHeader; 
                _knownHeaderIndex = HttpWorkerRequest.GetKnownResponseHeaderIndex(_unknownHeader);
                _value = value;
            }
        } 

        internal String Name { 
            get { 
                if (_unknownHeader != null)
                    return _unknownHeader; 
                else
                    return HttpWorkerRequest.GetKnownResponseHeaderName(_knownHeaderIndex);
            }
        } 

        internal String Value { 
            get { return _value; } 
        }
 
        internal void Send(HttpWorkerRequest wr) {
            if (_knownHeaderIndex >= 0)
                wr.SendKnownResponseHeader(_knownHeaderIndex, _value);
            else 
                wr.SendUnknownResponseHeader(_unknownHeader, _value);
        } 
 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK