示例#1
0
        private int GetNextBoundaryIndex(byte[] chunk, int searchStart, int countOfBytesToSearch, out bool lastBoundary)
        {
            lastBoundary = false;
            int num  = ByteComparer.IndexOf(this.LastBoundary, this._bufferedBytes, chunk, searchStart);
            int num2 = ByteComparer.IndexOf(this._searchedContentBoundary, this._bufferedBytes, chunk, searchStart);

            if ((num2 >= 0) && (num2 < countOfBytesToSearch))
            {
                return(num2);
            }
            if (num >= (countOfBytesToSearch + this._bufferedBytes.Length))
            {
                return(-1);
            }
            if (num >= 0)
            {
                lastBoundary = true;
            }
            return(num);
        }
 public void AddData(byte[] data, bool lastData)
 {
     if (!this._headerComplete)
     {
         int num = ByteComparer.IndexOf(_headerEnd, this._bufferedBytes, data, 0);
         int headerBytesToStore = (num < 0) ? data.Length : num;
         this._headerComplete = num >= 0;
         int length = this._bufferedBytes.Length;
         this.AddHeaderData(data, headerBytesToStore, !this._headerComplete);
         if (this._headerComplete)
         {
             this.Header              = this.CreateHeader(this._headerData);
             this._completeBodyBytes += ((data.Length - num) - _headerEnd.Length) + length;
         }
     }
     else
     {
         this._completeBodyBytes += data.Length;
     }
     this._complete = lastData;
 }