CutTail() 개인적인 메소드

private CutTail ( int count ) : void
count int
리턴 void
예제 #1
0
        private ByteVector ReadReply()
        {
            ByteVector vector = new ByteVector();

            byte[] buffer = new byte[0x200];
            do
            {
                int length = this.Receive(buffer);
                if (length == 0)
                {
                    return(vector);
                }
                vector.Add(buffer, 0, length);
                int offset = this.FindReplyEnd(vector.Data, vector.Size);
                if (offset > 0)
                {
                    if (offset < length)
                    {
                        this.PutBufferData(buffer, offset, length - offset);
                        vector.CutTail(length - offset);
                    }
                    return(vector);
                }
            }while (vector.Size <= this._maxReplySize);
            throw new ProtocolViolationException("Web proxy reply exceed maximum length.");
        }
예제 #2
0
        ByteVector ReadReply()
        {
            ByteVector reply = new ByteVector();

            byte[] buf = new byte[512];
            while (true)
            {
                int num = Receive(buf);
                if (0 == num)
                {
                    break;
                }

                reply.Add(buf, 0, num);

                // handle the end of reply
                int afterEndPos = FindReplyEnd(reply.Data, reply.Size);
                if (afterEndPos > 0)
                {
                    if (afterEndPos < num) // read after reply finished?
                    {
                        // put data back into the buffer for further
                        // processing in receive functions
                        PutBufferData(buf, afterEndPos, num - afterEndPos);
                        reply.CutTail(num - afterEndPos);
                    }

                    break;
                }

                if (reply.Size > _maxReplySize)
                {
                    throw new ProtocolViolationException("Web proxy reply exceed maximum length.");
                }
            }

            return(reply);
        }
		ByteVector ReadReply()
		{
			ByteVector reply = new ByteVector();
			byte[] buf = new byte[512];
			while(true)
			{
				int num = Receive(buf);
				if(0 == num)
					break;

				reply.Add(buf, 0, num);

				//handle the end of reply
				int afterEndPos = FindReplyEnd(reply.Data, reply.Size);
				if(afterEndPos > 0)
				{
					if(afterEndPos < num) //read after reply finished?
					{
						//put data back into the buffer for further
						//processing in receive functions
						PutBufferData(buf, afterEndPos, num - afterEndPos);
						reply.CutTail(num - afterEndPos);
					}
					break;
				}

				if(reply.Size > _maxReplySize)
					throw new ProtocolViolationException("Web proxy reply exceed maximum length.");
			}
			return reply;
		}