Пример #1
0
        public HttpParser ReasonPhrase(out Datagram reasonPhrase)
        {
            if (!this.Success)
            {
                reasonPhrase = (Datagram)null;
                return(this);
            }
            int num1 = 0;

            foreach (byte num2 in this.Range)
            {
                if (ByteExtensions.IsControl(num2))
                {
                    if ((int)num2 != 9)
                    {
                        break;
                    }
                }
                ++num1;
            }
            int length = Enumerable.Count <byte>(Enumerable.TakeWhile <byte>(this.Range, (Func <byte, bool>)(value =>
            {
                if (ByteExtensions.IsControl(value))
                {
                    return((int)value == 9);
                }
                return(true);
            })));

            reasonPhrase  = new Datagram(this._buffer, this._offset, length);
            this._offset += length;
            return(this);
        }
Пример #2
0
 public static bool IsToken(this byte value)
 {
     if (ByteExtensions.IsChar(value) && !ByteExtensions.IsControl(value))
     {
         return(!ByteExtensions.IsSeparator(value));
     }
     return(false);
 }
Пример #3
0
        public HttpParser QuotedString(out Datagram quotedString)
        {
            quotedString = (Datagram)null;
            int offset = this._offset;

            if (!this.Bytes((byte)34).Success)
            {
                return(this);
            }
            while (this.IsNext())
            {
                byte num1 = this.Next();
                switch (num1)
                {
                case (byte)34:
                    ++this._offset;
                    quotedString = new Datagram(this._buffer, offset, this._offset - offset);
                    return(this);

                case (byte)92:
                    if (this.IsNextNext() && ByteExtensions.IsChar(this.NextNext()))
                    {
                        this._offset += 2;
                        continue;
                    }
                    break;
                }
                int num2 = this._offset;
                this.SkipLws();
                if (num2 == this._offset)
                {
                    if (ByteExtensions.IsControl(num1))
                    {
                        return(this.Fail());
                    }
                    ++this._offset;
                }
            }
            return(this.Fail());
        }