Пример #1
0
 private long GetItemSize(HttpRequestItem item)
 {
     using (Stream stream = item.GetData())
     {
         return(stream.Length);
     }
 }
Пример #2
0
        private HttpRequestItem CreateMultiPartItem(string header)
        {
            ClearDataStream();
            string[] stringArray = StringUtils.GetStringArray(header);
            var      fieldList   = new HeaderFieldList();

            HeaderFieldList.GetHeaderFieldList(0, stringArray, fieldList);
            HttpRequestItem item = CreateItem(stringArray, fieldList);

            item.ParseHeader(stringArray, fieldList);
            return(item);
        }
Пример #3
0
 public GetDataStreamEventArgs(HttpRequestItem item)
 {
     this.item   = item;
     this.stream = null;
 }
Пример #4
0
        private void ParseMultiPartRequest(Stream stream)
        {
            int num4;

            byte[] bytes     = Encoding.ASCII.GetBytes("\r\n--" + Header.Boundary);
            var    buffer2   = new byte[] { 13, 10, 13, 10 };
            int    batchSize = BatchSize;

            if (batchSize < bytes.Length)
            {
                batchSize = bytes.Length;
            }
            if (batchSize > ((int)(stream.Length - stream.Position)))
            {
                batchSize = (int)(stream.Length - stream.Position);
            }
            string str = string.Empty;

            byte[]          data   = null;
            HttpRequestItem item   = null;
            int             index  = 2;
            int             num3   = 0;
            var             buffer = new byte[batchSize];

            while ((num4 = stream.Read(buffer, 0, batchSize)) > 0)
            {
                int num5;
                int num6 = 0;
                for (int i = 0; i < num4; i++)
                {
                    if (buffer[i] == bytes[index])
                    {
                        index++;
                    }
                    else
                    {
                        index = 0;
                        if (buffer[i] == bytes[index])
                        {
                            index++;
                        }
                        if ((data != null) && (item != null))
                        {
                            item.AddData(data, 0, data.Length);
                        }
                        data = null;
                    }
                    if (buffer[i] == buffer2[num3])
                    {
                        num3++;
                    }
                    else
                    {
                        num3 = 0;
                        if (buffer[i] == buffer2[num3])
                        {
                            num3++;
                        }
                    }
                    if (index >= bytes.Length)
                    {
                        num5 = ((i - num6) - index) + 1;
                        if (((item != null) && (num6 < num4)) && (num5 > 0))
                        {
                            item.AddData(buffer, num6, num5);
                            item.AfterAddData();
                        }
                        item  = null;
                        str   = string.Empty;
                        num6  = 0;
                        index = 0;
                    }
                    else if (item == null)
                    {
                        str = str + Encoding.ASCII.GetString(buffer, i, buffer.Length - i);
                        if (num3 >= buffer2.Length)
                        {
                            item = CreateMultiPartItem(str.Trim());
                            str  = string.Empty;
                            num6 = i + 1;
                        }
                    }
                    if (num3 >= buffer2.Length)
                    {
                        num3 = 0;
                    }
                }
                num5 = (num4 - num6) - index;
                if (((item != null) && (num6 < num4)) && (num5 > 0))
                {
                    if (index > 0)
                    {
                        var array = new byte[data.Length + index];
                        data.CopyTo(array, 0);
                        Array.Copy(buffer, num4 - index, array, data.Length, index);
                        data = array;
                    }
                    item.AddData(buffer, num6, num5);
                }
            }
        }
Пример #5
0
 public void Add(HttpRequestItem item)
 {
     base.List.Add(item);
 }
Пример #6
0
 public void Remove(HttpRequestItem item)
 {
     base.List.Remove(item);
 }
Пример #7
0
 public DataAddedEventArgs(HttpRequestItem item, System.IO.Stream stream)
 {
     this.item   = item;
     this.stream = stream;
 }