Exemplo n.º 1
0
        public void Resolve()
        {
            int leavel = 0;
            int record = 0;

            for (var index = 0; index + 1 < ReqText.Length;)
            {
                if (ReqText[index] == '\r' && ReqText[index + 1] == '\n')
                {
                    var line = ReqText.ToString(record, index - record);
                    if (leavel == 0)
                    {
                        var arr = line.Split(' ');
                        this.HttpMethod = arr[0];
                        this.Url        = arr[1];
                        if (!this.Url.Contains('?'))
                        {
                            this.Route = Uri.UnescapeDataString(this.Url);
                        }
                        else
                        {
                            var arr1 = this.Url.Split('?');
                            this.Route       = Uri.UnescapeDataString(arr1[0]);
                            this.QueryString = Uri.UnescapeDataString(arr1[1]);
                        }

                        this.Version = arr[2];
                        leavel++;
                    }
                    else if (leavel == 1)
                    {
                        if (string.IsNullOrEmpty(line))
                        {
                            leavel++;
                        }
                        else
                        {
                            this.Headers.Enqueue(line);
                        }
                    }
                    else
                    {
                        this.Content = ReqText.ToString(record, ReqText.Length - record);
                        break;
                    }
                    index += 2;
                    record = index;
                }
                index++;
            }
        }
Exemplo n.º 2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: 释放托管状态(托管对象)
                    ReqText.Clear();
                }

                // TODO: 释放未托管的资源(未托管的对象)并替代终结器
                // TODO: 将大型字段设置为 null
                disposedValue = true;
                Headers       = null;
                Content       = null;
            }
        }