internal void AddHeader(string header)
        {
            int num = header.IndexOf(':');

            if (num == -1 || num == 0)
            {
                this.context.ErrorMessage = "Bad Request";
                this.context.ErrorStatus  = 400;
                return;
            }
            string text  = header.Substring(0, num).Trim();
            string text2 = header.Substring(num + 1).Trim();
            string text3 = text.ToLower(CultureInfo.InvariantCulture);

            this.headers.SetInternal(text, text2);
            string text4 = text3;

            switch (text4)
            {
            case "accept-language":
                this.user_languages = text2.Split(new char[]
                {
                    ','
                });
                break;

            case "accept":
                this.accept_types = text2.Split(new char[]
                {
                    ','
                });
                break;

            case "content-length":
                try
                {
                    this.content_length = long.Parse(text2.Trim());
                    if (this.content_length < 0L)
                    {
                        this.context.ErrorMessage = "Invalid Content-Length.";
                    }
                    this.cl_set = true;
                }
                catch
                {
                    this.context.ErrorMessage = "Invalid Content-Length.";
                }
                break;

            case "referer":
                try
                {
                    this.referrer = new System.Uri(text2);
                }
                catch
                {
                    this.referrer = new System.Uri("http://someone.is.screwing.with.the.headers.com/");
                }
                break;

            case "cookie":
            {
                if (this.cookies == null)
                {
                    this.cookies = new CookieCollection();
                }
                string[] array = text2.Split(new char[]
                    {
                        ',',
                        ';'
                    });
                Cookie cookie = null;
                int    num3   = 0;
                foreach (string text5 in array)
                {
                    string text6 = text5.Trim();
                    if (text6.Length != 0)
                    {
                        if (text6.StartsWith("$Version"))
                        {
                            num3 = int.Parse(HttpListenerRequest.Unquote(text6.Substring(text6.IndexOf("=") + 1)));
                        }
                        else if (text6.StartsWith("$Path"))
                        {
                            if (cookie != null)
                            {
                                cookie.Path = text6.Substring(text6.IndexOf("=") + 1).Trim();
                            }
                        }
                        else if (text6.StartsWith("$Domain"))
                        {
                            if (cookie != null)
                            {
                                cookie.Domain = text6.Substring(text6.IndexOf("=") + 1).Trim();
                            }
                        }
                        else if (text6.StartsWith("$Port"))
                        {
                            if (cookie != null)
                            {
                                cookie.Port = text6.Substring(text6.IndexOf("=") + 1).Trim();
                            }
                        }
                        else
                        {
                            if (cookie != null)
                            {
                                this.cookies.Add(cookie);
                            }
                            cookie = new Cookie();
                            int num4 = text6.IndexOf("=");
                            if (num4 > 0)
                            {
                                cookie.Name  = text6.Substring(0, num4).Trim();
                                cookie.Value = text6.Substring(num4 + 1).Trim();
                            }
                            else
                            {
                                cookie.Name  = text6.Trim();
                                cookie.Value = string.Empty;
                            }
                            cookie.Version = num3;
                        }
                    }
                }
                if (cookie != null)
                {
                    this.cookies.Add(cookie);
                }
                break;
            }
            }
        }