예제 #1
0
        //- $TryReadAllHeaders -//
        private Boolean TryReadAllHeaders()
        {
            Byte[] src = this.Connection.ReadRequestBytes(0x8000);
            if ((src == null) || (src.Length == 0))
            {
                return(false);
            }
            if (this.HeaderBytes != null)
            {
                Int32 num = src.Length + this.HeaderBytes.Length;
                if (num > 0x8000)
                {
                    return(false);
                }
                Byte[] dst = new Byte[num];
                Buffer.BlockCopy(this.HeaderBytes, 0, dst, 0, this.HeaderBytes.Length);
                Buffer.BlockCopy(src, 0, dst, this.HeaderBytes.Length, src.Length);
                this.HeaderBytes = dst;
            }
            else
            {
                this.HeaderBytes = src;
            }
            //+
            this.StartHeadersOffset = -1;
            this.EndHeadersOffset   = -1;
            this.HeaderByteStrings  = new ArrayList();
            //+
            ByteParser parser = new ByteParser(this.HeaderBytes);

            while (true)
            {
                ByteString str = parser.ReadLine();
                if (str == null)
                {
                    break;
                }
                if (this.StartHeadersOffset < 0)
                {
                    this.StartHeadersOffset = parser.CurrentOffset;
                }
                if (str.IsEmpty)
                {
                    this.EndHeadersOffset = parser.CurrentOffset;
                    break;
                }
                //+
                this.HeaderByteStrings.Add(str);
            }
            return(true);
        }
예제 #2
0
        private bool TryReadAllHeaders()
        {
            byte[] src = _connection.ReadHeadersAsByte();

            if ((src == null) || (src.Length == 0))
            {
                return(false);
            }
            if (_headerBytes != null)
            {
                int num = src.Length + _headerBytes.Length;
                if (num > 0x8000)
                {
                    return(false);
                }
                byte[] dst = new byte[num];
                Buffer.BlockCopy(_headerBytes, 0, dst, 0, _headerBytes.Length);
                Buffer.BlockCopy(src, 0, dst, _headerBytes.Length, src.Length);
                _headerBytes = dst;
            }
            else
            {
                _headerBytes = src;
            }
            _startHeadersOffset = -1;
            _endHeadersOffset   = -1;
            _headerByteStrings  = new ArrayList();
            ByteParser parser = new ByteParser(_headerBytes);

            while (true)
            {
                ByteString str = parser.ReadLine();
                if (str == null)
                {
                    break;
                }
                if (_startHeadersOffset < 0)
                {
                    _startHeadersOffset = parser.CurrentOffset;
                }
                if (str.IsEmpty)
                {
                    _endHeadersOffset = parser.CurrentOffset;
                    break;
                }
                _headerByteStrings.Add(str);
            }
            return(true);
        }
예제 #3
0
        private bool TryReadAllHeaders()
        {
            // read the first packet (up to 32K)
            byte[] headerBytes = _connection.ReadRequestBytes(MaxHeaderBytes);

            if (headerBytes == null || headerBytes.Length == 0)
                return false;

            if (_headerBytes != null)
            {
                // previous partial read
                int len = headerBytes.Length + _headerBytes.Length;
                if (len > MaxHeaderBytes)
                    return false;

                var bytes = new byte[len];
                Buffer.BlockCopy(_headerBytes, 0, bytes, 0, _headerBytes.Length);
                Buffer.BlockCopy(headerBytes, 0, bytes, _headerBytes.Length, headerBytes.Length);
                _headerBytes = bytes;
            }
            else
            {
                _headerBytes = headerBytes;
            }

            // start parsing
            _startHeadersOffset = -1;
            _endHeadersOffset = -1;
            _headerByteStrings = new List<ByteString>();

            // find the end of headers
            var parser = new ByteParser(_headerBytes);

            for (; ; )
            {
                ByteString line = parser.ReadLine();

                if (line == null)
                {
                    break;
                }

                if (_startHeadersOffset < 0)
                {
                    _startHeadersOffset = parser.CurrentOffset;
                }

                if (line.IsEmpty)
                {
                    _endHeadersOffset = parser.CurrentOffset;
                    break;
                }

                _headerByteStrings.Add(line);
            }

            return true;
        }
예제 #4
0
파일: Request.cs 프로젝트: icnocop/Huygens
        private bool TryReadAllHeaders()
        {
            // read the first packet (up to 32K)
            byte[] headerBytes = _connection.ReadRequestBytes(MaxHeaderBytes);

            if (headerBytes == null || headerBytes.Length == 0)
            {
                return(false);
            }

            if (_headerBytes != null)
            {
                // previous partial read
                int len = headerBytes.Length + _headerBytes.Length;
                if (len > MaxHeaderBytes)
                {
                    return(false);
                }

                var bytes = new byte[len];
                Buffer.BlockCopy(_headerBytes, 0, bytes, 0, _headerBytes.Length);
                Buffer.BlockCopy(headerBytes, 0, bytes, _headerBytes.Length, headerBytes.Length);
                _headerBytes = bytes;
            }
            else
            {
                _headerBytes = headerBytes;
            }

            // start parsing
            _startHeadersOffset = -1;
            _endHeadersOffset   = -1;
            _headerByteStrings  = new List <ByteString>();

            // find the end of headers
            var parser = new ByteParser(_headerBytes);

            for (; ;)
            {
                var line = parser.ReadLine();

                if (line == null)
                {
                    break;
                }

                if (_startHeadersOffset < 0)
                {
                    _startHeadersOffset = parser.CurrentOffset;
                }

                if (line.IsEmpty)
                {
                    _endHeadersOffset = parser.CurrentOffset;
                    break;
                }

                _headerByteStrings.Add(line);
            }

            return(true);
        }