Example #1
0
        public void Clear()
        {
            head.Clear();
            HTTPPackageLinkNode next = head.nextNode;

            while (next != null)
            {
                next.nextNode = null;
                next.Clear();
                next = next.nextNode;
            }
        }
        public HTTPPackageLinkNode AddBuffer(byte[] data, long sourcesIndex, long length)
        {
            long totolLength = index + length;

            if (totolLength <= buffer.Length)
            {
                Array.Copy(data, sourcesIndex, buffer, index, length);
                index += length;
                return(this);
            }
            else
            {
                long tmpLength = buffer.Length - index;
                Array.Copy(data, sourcesIndex, buffer, index, tmpLength);
                index   += tmpLength;
                nextNode = CreateNewNode();
                return(nextNode.AddBuffer(data, sourcesIndex + tmpLength, length - tmpLength));
            }
        }
Example #3
0
        public byte[] GetData()
        {
            if (bufferCount.Equals(0))
            {
                return(null);
            }

            byte[] data  = new byte[bufferCount];
            long   index = 0;

            head.GetData(data, ref index);
            HTTPPackageLinkNode next = head.nextNode;

            while (next != null)
            {
                next.GetData(data, ref index);
                next = next.nextNode;
            }
            return(data);
        }
Example #4
0
 public void AddBuffer(byte[] data, long length)
 {
     bufferCount += length;
     now          = now.AddBuffer(data, 0, length);
 }
Example #5
0
 public HTTPPackage(int bufferSize)
 {
     this.bufferSize = bufferSize;
     head            = new HTTPPackageLinkNode(bufferSize);
     now             = head;
 }