private void doWithCheckingState(Action<string, string> action, string name, string value, bool response, bool setState)
 {
     CheckState(response);
     action(name, value);
     if (setState && _state == HttpHeaderType.Unspecified)
         _state = response ? HttpHeaderType.Response : HttpHeaderType.Request;
 }
Beispiel #2
0
 public HeaderCollection(HttpHeaderType httpHeaderType)
 {
     _cookies          = new HeaderCookieCollection(this);
     _cookieHeaderName = httpHeaderType == HttpHeaderType.ResponseHeader
         ? ResponseCookieHeaderName
         : RequestCookieHeaderName;
 }
Beispiel #3
0
        public KnownHeader(string name, HttpHeaderType headerType, HttpHeaderParser?parser, string[]?knownValues = null, int?http2StaticTableIndex = null, int?http3StaticTableIndex = null)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));
            Debug.Assert(name[0] == ':' || HttpRuleParser.GetTokenLength(name, 0) == name.Length);

            Name        = name;
            HeaderType  = headerType;
            Parser      = parser;
            KnownValues = knownValues;

            Http2EncodedName = http2StaticTableIndex.HasValue ?
                               HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexingToAllocatedArray(http2StaticTableIndex.GetValueOrDefault()) :
                               HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexingNewNameToAllocatedArray(name);

            Http3EncodedName = http3StaticTableIndex.HasValue ?
                               QPack.QPackEncoder.EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(http3StaticTableIndex.GetValueOrDefault()) :
                               QPack.QPackEncoder.EncodeLiteralHeaderFieldWithoutNameReferenceToArray(name);

            var asciiBytesWithColonSpace = new byte[name.Length + 2]; // + 2 for ':' and ' '
            int asciiBytes = Encoding.ASCII.GetBytes(name, asciiBytesWithColonSpace);

            Debug.Assert(asciiBytes == name.Length);
            asciiBytesWithColonSpace[asciiBytesWithColonSpace.Length - 2] = (byte)':';
            asciiBytesWithColonSpace[asciiBytesWithColonSpace.Length - 1] = (byte)' ';
            AsciiBytesWithColonSpace = asciiBytesWithColonSpace;
        }
Beispiel #4
0
        protected virtual void GetGValue(BattleCharItem item)
        {
            if (null == item)
            {
                return;
            }
            //index=0&xtoken=74c15f4a-347a-4c8e-b7aa-26704ac45ad9
            const string PostGFormat = "index={0}{1}";
            //lastMailId=0&xtoken=24d9b826-251b-4e42-ad80-dc775ad6ccee
            const string firstPostGFormate = "lastMailId=0{0}";

            string gUrl     = this.DetectionParamsItem.CurrentGameServer.BattleGSelectCharUrl;
            string postData = string.Empty;

            if (item.Index <= 0)
            {
                postData = string.Format(firstPostGFormate, this.GetGxstoken());
            }
            else
            {
                postData = string.Format(PostGFormat, item.Index, this.GetGxstoken());
            }
            string html = string.Empty;

            if (item.Index > 0)
            {
                html = this.ReadUrlContent(gUrl, postData);
            }
            //html = this.ReadFromUrl(item.Href);
            if (!isQueryed)
            {
                this.httpHeaderType = HttpHeaderType.XmlHttpRequest;
                html = this.ReadFromUrl(this.DetectionParamsItem.CurrentGameServer.BattleGetGUrl);
                this.httpHeaderType = HttpHeaderType.Normal;
                isQueryed           = true;
            }
            int i = 0;

            do
            {
                this.httpHeaderType = HttpHeaderType.Json;
                html = this.ReadFromUrl(this.DetectionParamsItem.CurrentGameServer.BattleGetGUrlMoney, true);
                this.httpHeaderType = HttpHeaderType.Normal;

                string moneyDiv = "\"money\"";
                if (TextHelper.IsContains(html, moneyDiv))
                {
                    JsonData jd    = JsonMapper.ToObject(html);
                    int      money = (int)jd["money"];
                    item.Money  = money.ToString();
                    item.Gold   = money / 10000;
                    item.Sliver = (money - item.Gold * 10000) / 100;
                    item.Copper = money - item.Gold * 10000 - item.Sliver * 100;
                    return;
                }
                this.LogManager.Error(string.Format("Char:{0} get G 值失败,开始重试:{1}", item.Name, postData));
            } while (i++ < 1);

            item.Money = "取不到G值或者出错";
        }
 private void SetState(bool response)
 {
     if (this.state == HttpHeaderType.Unspecified)
     {
         this.state = ((!response) ? HttpHeaderType.Request : HttpHeaderType.Response);
     }
 }
Beispiel #6
0
 public HeaderDescriptionAttribute(HttpHeaderType type, string name, string comments = null, bool optional = false)
 {
     Type     = type;
     Name     = name;
     Comments = comments;
     Optional = optional;
 }
Beispiel #7
0
 public HttpHeaderRule(HttpHeaderType headerType, HttpVerb verb, string name, HttpHeaderAction action, string value)
 {
     HeaderType = headerType;
     Verb       = verb;
     Name       = name;
     Action     = action;
     Value      = value;
 }
Beispiel #8
0
        public KnownHeader(string name)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));
            Debug.Assert(HttpRuleParser.GetTokenLength(name, 0) == name.Length);

            _name       = name;
            _headerType = HttpHeaderType.Custom;
            _parser     = null;
        }
Beispiel #9
0
 private void doWithCheckingState(Action <string, string> action, string name, string value, bool response, bool setState)
 {
     this.checkState(response);
     action(name, value);
     if ((!setState ? false : this._state == HttpHeaderType.Unspecified))
     {
         this._state = (response ? HttpHeaderType.Response : HttpHeaderType.Request);
     }
 }
Beispiel #10
0
        public KnownHeader(string name, HttpHeaderType headerType, HttpHeaderParser parser)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));
            Debug.Assert(HttpRuleParser.GetTokenLength(name, 0) == name.Length);
            Debug.Assert(headerType != HttpHeaderType.Custom);
            Debug.Assert(parser != null);

            _name       = name;
            _headerType = headerType;
            _parser     = parser;
        }
Beispiel #11
0
        private string ApplyHttpHeaderRules(string httpHeader, HttpHeaderType headerType, string httpRequestVerb, string lineBreak)
        {
            try
            {
                var availableRules = (from o in _route.HttpHeaderRules.List
                                      where
                                      (o.HeaderType == headerType || o.HeaderType == HttpHeaderType.Any) &&
                                      (o.Verb.ToString().ToUpper() == httpRequestVerb.ToUpper() || o.Verb == HttpVerb.Any) &&
                                      o.Enabled == true
                                      select o).ToList();

                foreach (var rule in availableRules)
                {
                    if (rule.Action == HttpHeaderAction.Upsert)
                    {
                        httpHeader = HttpUtility.UpsertHttpHostHeaderValue(httpHeader, rule.Name, rule.Value, lineBreak);
                    }
                    else if (rule.Action == HttpHeaderAction.Update)
                    {
                        httpHeader = HttpUtility.UpdateHttpHostHeaderValue(httpHeader, rule.Name, rule.Value, lineBreak);
                    }
                    else if (rule.Action == HttpHeaderAction.Insert)
                    {
                        httpHeader = HttpUtility.InsertHttpHostHeaderValue(httpHeader, rule.Name, rule.Value, lineBreak);
                    }
                    else if (rule.Action == HttpHeaderAction.Delete)
                    {
                        httpHeader = HttpUtility.DeleteHttpHostHeaderValue(httpHeader, rule.Name, lineBreak);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
            }
            catch (Exception ex)
            {
                Singletons.EventLog.WriteEvent(new EventLogging.EventPayload
                {
                    Severity   = EventLogging.Severity.Error,
                    CustomText = "Failed to process HTTP Header rules.",
                    Exception  = ex
                });
            }

            return(httpHeader);
        }
Beispiel #12
0
        private void doWithCheckingState(Action <string, string> action, string name, string value, bool setState)
        {
            HttpHeaderType httpHeaderType = WebHeaderCollection.checkHeaderType(name);

            if (httpHeaderType == HttpHeaderType.Request)
            {
                this.doWithCheckingState(action, name, value, false, setState);
            }
            else if (httpHeaderType != HttpHeaderType.Response)
            {
                action(name, value);
            }
            else
            {
                this.doWithCheckingState(action, name, value, true, setState);
            }
        }
Beispiel #13
0
        public KnownHeader(string name, HttpHeaderType headerType, HttpHeaderParser parser, string[] knownValues = null)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));
            Debug.Assert(HttpRuleParser.GetTokenLength(name, 0) == name.Length);
            Debug.Assert((headerType == HttpHeaderType.Custom) == (parser == null));
            Debug.Assert(knownValues == null || headerType != HttpHeaderType.Custom);

            _name        = name;
            _headerType  = headerType;
            _parser      = parser;
            _knownValues = knownValues;

            _asciiBytesWithColonSpace = new byte[name.Length + 2]; // + 2 for ':' and ' '
            Array.Copy(Encoding.ASCII.GetBytes(name), _asciiBytesWithColonSpace, name.Length);
            _asciiBytesWithColonSpace[_asciiBytesWithColonSpace.Length - 2] = (byte)':';
            _asciiBytesWithColonSpace[_asciiBytesWithColonSpace.Length - 1] = (byte)' ';
        }
Beispiel #14
0
        public override void Add(string name, string value)
        {
            var type = CheckHeaderType(name);

            if (type == HttpHeaderType.Unspecified)
            {
                base.Add(name, CheckValue(value));
            }
            else
            {
                CheckState(type == HttpHeaderType.Response);

                base.Add(name, CheckValue(value));

                State = type == HttpHeaderType.Response ? HttpHeaderType.Response : HttpHeaderType.Request;
            }
        }
Beispiel #15
0
        public KnownHeader(string name, HttpHeaderType headerType, HttpHeaderParser?parser, string[]?knownValues = null, int?http2StaticTableIndex = null, int?http3StaticTableIndex = null)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));
            Debug.Assert(name[0] == ':' || HttpRuleParser.GetTokenLength(name, 0) == name.Length);

            Name        = name;
            HeaderType  = headerType;
            Parser      = parser;
            KnownValues = knownValues;

            Initialize(http2StaticTableIndex, http3StaticTableIndex);

            var asciiBytesWithColonSpace = new byte[name.Length + 2]; // + 2 for ':' and ' '
            int asciiBytes = Encoding.ASCII.GetBytes(name, asciiBytesWithColonSpace);

            Debug.Assert(asciiBytes == name.Length);
            asciiBytesWithColonSpace[asciiBytesWithColonSpace.Length - 2] = (byte)':';
            asciiBytesWithColonSpace[asciiBytesWithColonSpace.Length - 1] = (byte)' ';
            AsciiBytesWithColonSpace = asciiBytesWithColonSpace;
        }
 protected WebHeaderCollection(SerializationInfo serializationInfo, StreamingContext streamingContext)
 {
     if (serializationInfo == null)
     {
         throw new ArgumentNullException("serializationInfo");
     }
     try
     {
         this.internallyCreated = serializationInfo.GetBoolean("InternallyCreated");
         this.state             = (HttpHeaderType)serializationInfo.GetInt32("State");
         int @int = serializationInfo.GetInt32("Count");
         for (int i = 0; i < @int; i++)
         {
             base.Add(serializationInfo.GetString(i.ToString()), serializationInfo.GetString((@int + i).ToString()));
         }
     }
     catch (SerializationException ex)
     {
         throw new ArgumentException(ex.Message, "serializationInfo", ex);
     }
 }
 protected WebHeaderCollection(SerializationInfo serializationInfo, StreamingContext streamingContext)
 {
     if (serializationInfo == null)
     {
         throw new ArgumentNullException("serializationInfo");
     }
     try
     {
         this._internallyUsed = serializationInfo.GetBoolean("InternallyUsed");
         this._state          = (HttpHeaderType)serializationInfo.GetInt32("State");
         int num = serializationInfo.GetInt32("Count");
         for (int i = 0; i < num; i++)
         {
             int num3 = num + i;
             base.Add(serializationInfo.GetString(i.ToString()), serializationInfo.GetString(num3.ToString()));
         }
     }
     catch (SerializationException exception)
     {
         throw new ArgumentException(exception.Message, "serializationInfo", exception);
     }
 }
Beispiel #18
0
 /// <summary>
 /// Removes all headers from the collection.
 /// </summary>
 public override void Clear()
 {
     base.Clear();
     State = HttpHeaderType.Unspecified;
 }
 internal HttpHeaderInfo(string name, HttpHeaderType type)
 {
     _name = name;
       _type = type;
 }
 public WebHeaderCollection()
 {
     _state = HttpHeaderType.Unspecified;
 }
 internal WebHeaderCollection(bool internallyCreated)
 {
     _internallyCreated = internallyCreated;
     _state             = HttpHeaderType.Unspecified;
 }
 internal HttpHeaders(HttpHeaderType allowedHeaderTypes, HttpHeaderType treatAsCustomHeaderTypes)
 {
     this._allowedHeaderTypes       = allowedHeaderTypes;
     this._treatAsCustomHeaderTypes = treatAsCustomHeaderTypes;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WebHeaderCollection"/> class.
 /// </summary>
 public WebHeaderCollection()
 {
     internallyCreated = false;
     state = HttpHeaderType.Unspecified;
 }
Beispiel #24
0
 internal HttpHeaderInfo(string name, HttpHeaderType type)
 {
     Name = name;
     Type = type;
 }
Beispiel #25
0
        protected override void SetHttpRequestHeader(HttpWebRequest httpRequest, bool isPost, HttpHeaderType headerType)
        {
            base.SetHttpRequestHeader(httpRequest, isPost, headerType);
            //if (isPost)
            //{
            //    httpRequest.Accept = @"*/*";
            //    httpRequest.Referer = this.DetectionParamsItem.GameServer.BattleCharacterUrl;
            //}

            switch (headerType)
            {
            case HttpHeaderType.Json:
                httpRequest.UserAgent = @"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)";
                httpRequest.Accept    = @"application/json, text/javascript, */*; q=0.01";
                //httpRequest.Referer = @"http://eu.battle.net/wow/en/vault/character/auction/alliance/";
                httpRequest.Referer       = this.DetectionParamsItem.CurrentGameServer.BattleGetGUrl;
                httpRequest.ContentLength = 0;
                httpRequest.ContentType   = string.Empty;
                // httpRequest.ContentType = "application/json;charset=utf-8";
                // httpRequest.AllowAutoRedirect = false;
                // httpRequest.Headers.Add(HttpRequestHeader.ContentLength, "0");
                httpRequest.Headers.Add(HttpRequestHeader.Pragma, "no-cache");
                break;

            case HttpHeaderType.XmlHttpRequest:
                httpRequest.ContentType = "application/x-www-form-urlencoded";
                httpRequest.Accept      = "*/*";
                httpRequest.UserAgent   = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
                break;

            default:
                break;
            }
        }
Beispiel #26
0
        void ProcessReceivedData(SocketState connection, byte[] buffer, int bufferSize)
        {
            string sharedSecretString = connection.Peer.IsEncryptionNegotationComplete ? connection.Peer.KeyNegotiator.SharedSecretString : null;

            string commonSalt = null;

            if (connection.Peer.IsIncomming && connection.Peer.IsEncryptionNegotationComplete)
            {
                commonSalt = _route.BindingPreSharedKey;
            }
            else if (connection.Peer.IsOutgoing && connection.Peer.IsEncryptionNegotationComplete)
            {
                commonSalt = _route.EndpointPreSharedKey;
            }

            if (_route.TrafficType == TrafficType.Http)
            {
                HttpHeaderType httpHeaderType = HttpHeaderType.None;

                string httpHeader      = null;
                string httpRequestVerb = string.Empty;

                if (connection.HttpHeaderBuilder != string.Empty)
                {
                    //This is a continuation of a previously received fragmented header.
                    httpHeader     = (connection.HttpHeaderBuilder ?? string.Empty) + Encoding.UTF8.GetString(buffer);
                    httpHeaderType = HttpUtility.IsHttpHeader(httpHeader, out httpRequestVerb);
                }
                else
                {
                    httpHeaderType = HttpUtility.IsHttpHeader(buffer, bufferSize, out httpRequestVerb);

                    if (httpHeaderType != HttpHeaderType.None)
                    {
                        httpHeader = Encoding.UTF8.GetString(buffer);
                    }
                }

                if (httpHeaderType != HttpHeaderType.None)
                {
                    string lineBreak      = "";
                    int    endOfHeaderPos = HttpUtility.GetHttpHeaderEnd(httpHeader, out lineBreak);

                    if (endOfHeaderPos < 0)
                    {
                        throw new NotSupportedException(); //Not sure what to do yet.
                    }

                    if (endOfHeaderPos > bufferSize)
                    {
                        throw new InvalidOperationException(); //Not sure what to do yet.
                    }

                    httpHeader  = httpHeader.Substring(0, endOfHeaderPos).Trim(new char[] { '\r', '\n', ' ', '\0' });
                    httpHeader  = ApplyHttpHeaderRules(httpHeader, httpHeaderType, httpRequestVerb, lineBreak);
                    httpHeader += lineBreak + lineBreak; //Terminate the header.

                    int contentLength = bufferSize - (endOfHeaderPos - connection.HttpHeaderBuilder.Length);
                    connection.HttpHeaderBuilder = string.Empty;

                    byte[] fullReponse = new byte[httpHeader.Length + contentLength];

                    Buffer.BlockCopy(System.Text.Encoding.UTF8.GetBytes(httpHeader), 0, fullReponse, 0, httpHeader.Length);
                    if (contentLength > 0)
                    {
                        Buffer.BlockCopy(buffer, endOfHeaderPos, fullReponse, httpHeader.Length, contentLength);
                    }

                    if (connection.Peer.UsePackets)
                    {
                        //Console.WriteLine("--Send:{0}, Packet: {1}", route.Name, Encoding.UTF8.GetString(fullReponse.Take(fullReponse.Length).ToArray()));

                        byte[] sendBuffer = Packetizer.AssembleMessagePacket(fullReponse, fullReponse.Length, connection.Peer.UseCompression, connection.Peer.UseEncryption, sharedSecretString, commonSalt);
                        Stats.BytesSent += (UInt64)sendBuffer.Length;
                        connection.Peer.Socket.Send(sendBuffer, sendBuffer.Length, SocketFlags.None);
                        WaitForData(connection);
                    }
                    else
                    {
                        //Console.WriteLine("--Send:{0}, Raw: {1}", route.Name, Encoding.UTF8.GetString(fullReponse.Take(fullReponse.Length).ToArray()));

                        Stats.BytesSent += (UInt64)fullReponse.Length;
                        connection.Peer.Socket.Send(fullReponse, fullReponse.Length, SocketFlags.None);
                    }

                    return;
                }
            }

            if (connection.Peer.UsePackets)
            {
                //Console.WriteLine("--Send:{0}, Packet: {1}", route.Name, Encoding.UTF8.GetString(buffer.Take(bufferSize).ToArray()));

                byte[] sendBuffer = Packetizer.AssembleMessagePacket(buffer, bufferSize, connection.Peer.UseCompression, connection.Peer.UseEncryption, sharedSecretString, commonSalt);
                Stats.BytesSent += (UInt64)sendBuffer.Length;
                connection.Peer.Socket.Send(sendBuffer, sendBuffer.Length, SocketFlags.None);
            }
            else
            {
                //Console.WriteLine("--Send:{0}, Raw: {1}", route.Name, Encoding.UTF8.GetString(buffer.Take(bufferSize).ToArray()));

                Stats.BytesSent += (UInt64)bufferSize;
                connection.Peer.Socket.Send(buffer, bufferSize, SocketFlags.None);
            }
        }
 internal HttpHeaderInfo(string name, HttpHeaderType type)
 {
     this._name = name;
     this._type = type;
 }
 public WebHeaderCollection()
 {
     this.internallyCreated = false;
     this.state             = HttpHeaderType.Unspecified;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="WebHeaderCollection"/> class
        /// with the specified <see cref="SerializationInfo"/> and <see cref="StreamingContext"/>.
        /// </summary>
        /// <param name="serializationInfo">
        /// A <see cref="SerializationInfo"/> that contains the data to need to serialize the <see cref="WebHeaderCollection"/> object.
        /// </param>
        /// <param name="streamingContext">
        /// A <see cref="StreamingContext"/> that contains the source of the serialized stream associated with the new <see cref="WebHeaderCollection"/>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="serializationInfo"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// An element with the specified name is not found in <paramref name="serializationInfo"/>.
        /// </exception>
        protected WebHeaderCollection(
			SerializationInfo serializationInfo, StreamingContext streamingContext)
        {
            if (serializationInfo == null)
                throw new ArgumentNullException ("serializationInfo");

            try {
                internallyCreated = serializationInfo.GetBoolean ("InternallyCreated");
                state = (HttpHeaderType) serializationInfo.GetInt32 ("State");

                int count = serializationInfo.GetInt32 ("Count");
                for (int i = 0; i < count; i++) {
                    base.Add (
                        serializationInfo.GetString (i.ToString ()),
                        serializationInfo.GetString ((count + i).ToString ()));
                }
            } catch (SerializationException ex) {
                throw new ArgumentException (ex.Message, "serializationInfo", ex);
            }
        }
Beispiel #30
0
 internal WebHeaderCollection(HttpHeaderType state, bool internallyUsed)
 {
     State           = state;
     _internallyUsed = internallyUsed;
 }
Beispiel #31
0
 internal HttpHeaderInfo(string headerName, HttpHeaderType headerType)
 {
     _headerName = headerName;
     _headerType = headerType;
 }
Beispiel #32
0
        protected virtual void SetHttpRequestHeader(HttpWebRequest httpRequest, bool isPost, HttpHeaderType headerType)
        {
            bool isSetXMLHttpRequest = false;

            if (isPost)
            {
                base.SetHttpRequestPostHeader(httpRequest);
                httpRequest.Headers.Add("x-requested-with", "XMLHttpRequest");
                isSetXMLHttpRequest = true;
                httpRequest.Accept  = @"*/*";
                //httpRequest.Referer = @"http://eu.battle.net/wow/en/forum/";
                httpRequest.Referer = this.DetectionParamsItem.CurrentGameServer.BattleGetGUrl;
            }
            else
            {
                base.SetHttpRequestGetHeader(httpRequest);
            }

            switch (headerType)
            {
            case HttpHeaderType.Json:
                httpRequest.UserAgent = @".NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E; CIBA)";
                httpRequest.Accept    = @"application/json, text/javascript, */*; q=0.01";

                if (!isSetXMLHttpRequest)
                {
                    httpRequest.Headers.Add("x-requested-with", "XMLHttpRequest");
                }
                //httpRequest.Referer = @"http://eu.battle.net/wow/en/vault/character/auction/alliance/";
                httpRequest.Referer       = this.DetectionParamsItem.CurrentGameServer.BattleGetGUrl;
                httpRequest.ContentLength = 0;
                break;

            case HttpHeaderType.XmlHttpRequest:
                httpRequest.Accept    = "*/*";
                httpRequest.Referer   = this.DetectionParamsItem.CurrentGameServer.BattleCharacterUrl;
                httpRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
                break;

            default:
                break;
            }
        }
 internal WebHeaderCollection (HttpHeaderType state, bool internallyUsed)
 {
   _state = state;
   _internallyUsed = internallyUsed;
 }
 void SetState(bool response)
 {
     if (state == HttpHeaderType.Unspecified)
         state = response
                 ? HttpHeaderType.Response
                 : HttpHeaderType.Request;
 }
 private void doWithCheckingState (
   Action <string, string> action, string name, string value, bool response, bool setState)
 {
   checkState (response);
   action (name, value);
   if (setState && _state == HttpHeaderType.Unspecified)
     _state = response ? HttpHeaderType.Response : HttpHeaderType.Request;
 }
 internal WebHeaderCollection(bool internallyCreated)
 {
     this.internallyCreated = internallyCreated;
     state = HttpHeaderType.Unspecified;
 }
 /// <summary>
 /// Removes all headers from the collection.
 /// </summary>
 public override void Clear()
 {
     base.Clear ();
     state = HttpHeaderType.Undefined;
 }
 /// <summary>
 /// Removes all headers from the collection.
 /// </summary>
 public override void Clear()
 {
     base.Clear ();
     state = HttpHeaderType.Unspecified;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WebHeaderCollection"/> class.
 /// </summary>
 public WebHeaderCollection ()
 {
   _state = HttpHeaderType.Unspecified;
 }