Esempio n. 1
0
        private void TryDecodeLength(IChannelHandlerContext context, IByteBuffer buf, List <object> output)
        {
            if (!buf.IsReadable())
            {
                this.RequestReplay();
                return;
            }

            int endIndex = ByteBufferUtil.IndexOf(buf, buf.ReaderIndex, buf.ReaderIndex + buf.ReadableBytes, (byte)'\r');
            int num      = endIndex < 0 ? -1 : endIndex - buf.ReaderIndex;

            if (num == -1)
            {
                this.RequestReplay();
                return;
            }
            var bytes = new byte[num];

            buf.ReadBytes(bytes);
            this.BodyLength = Convert.ToInt32(Encoding.ASCII.GetString(bytes));
            this.Checkpoint(DecodeState.CRLF);
        }