Ejemplo n.º 1
0
        public static void ParseHttpHeader(string headerData, HttpHeaderInfo header)
        {
            string       text         = string.Empty;
            string       text2        = string.Empty;
            string       str          = string.Empty;
            StringReader stringReader = new StringReader(headerData);
            Dictionary <string, string> dictionary = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            string text3;

            while (!string.IsNullOrEmpty(text3 = stringReader.ReadLine()))
            {
                if (string.IsNullOrEmpty(text))
                {
                    text = text3;
                    continue;
                }
                if (text3.StartsWith("\t") && !string.IsNullOrEmpty(text2))
                {
                    str = (header[text2] = str + text3.Trim());
                    continue;
                }
                int num = text3.IndexOf(':');
                if (num <= 0)
                {
                    continue;
                }
                string text5 = text3.Substring(0, num);
                if (!string.IsNullOrEmpty(text5))
                {
                    text5 = text5.Trim();
                }
                int num2 = num + 1;
                if (text3.Length <= num2)
                {
                    continue;
                }
                string text6 = text3.Substring(num2);
                if (!string.IsNullOrEmpty(text6) && text6.StartsWith(" ") && text6.Length > 1)
                {
                    text6 = text6.Substring(1);
                }
                if (!string.IsNullOrEmpty(text5))
                {
                    if (dictionary.ContainsKey(text5))
                    {
                        str = (header[text5] = header[text5] + ", " + text6);
                    }
                    else
                    {
                        str = (header[text5] = text6);
                        dictionary.Add(text5, text5);
                    }
                    text2 = text5;
                }
            }
            string[] array = text.Split(' ');
            header.Method  = array[0];
            header.Path    = array[1];
            header.Version = array[2];
        }
        public override TPackageInfo ResolvePackage(IBufferStream bufferStream)
        {
            int            num        = (int)bufferStream.Length;
            string         headerData = bufferStream.ReadString(num, HeaderEncoding);
            HttpHeaderInfo header     = new HttpHeaderInfo();

            MimeHeaderHelper.ParseHttpHeader(headerData, header);
            IReceiveFilter <TPackageInfo> bodyReceiveFilter = GetBodyReceiveFilter(header, num);

            if (bodyReceiveFilter != null)
            {
                base.NextReceiveFilter = bodyReceiveFilter;
                bufferStream.Clear();
                return(default(TPackageInfo));
            }
            return(ResolveHttpPackageWithoutBody(header));
        }
 // Token: 0x06000731 RID: 1841 RVA: 0x0000629F File Offset: 0x0000449F
 protected HttpPackageInfoBase(string key, HttpHeaderInfo header, TRequestBody body) : base(key, header)
 {
     this.Body = body;
 }
 // Token: 0x0600072E RID: 1838 RVA: 0x00006278 File Offset: 0x00004478
 protected HttpPackageInfoBase(string key, HttpHeaderInfo header)
 {
     this.Key    = key;
     this.Header = header;
 }
 protected abstract TPackageInfo ResolveHttpPackageWithoutBody(HttpHeaderInfo header);
 protected abstract IReceiveFilter <TPackageInfo> GetBodyReceiveFilter(HttpHeaderInfo header, int headerSize);