예제 #1
0
        private void ParseRequest()
        {
            _http1Connection.Reset();

            if (!_http1Connection.TakeStartLine(_buffer, out var consumed, out var examined))
            {
                ErrorUtilities.ThrowInvalidRequestLine();
            }

            if (!_http1Connection.TakeMessageHeaders(_buffer, out consumed, out examined))
            {
                ErrorUtilities.ThrowInvalidRequestHeaders();
            }
        }
예제 #2
0
        private void ParseDataDrainBuffer()
        {
            var awaitable = Pipe.Reader.ReadAsync();

            if (!awaitable.IsCompleted)
            {
                // No more data
                return;
            }

            var readableBuffer = awaitable.GetResult().Buffer;

            do
            {
                Http1Connection.Reset();

                if (!Http1Connection.TakeStartLine(readableBuffer, out var consumed, out var examined))
                {
                    ErrorUtilities.ThrowInvalidRequestLine();
                }

                readableBuffer = readableBuffer.Slice(consumed);

                if (!Http1Connection.TakeMessageHeaders(readableBuffer, out consumed, out examined))
                {
                    ErrorUtilities.ThrowInvalidRequestHeaders();
                }

                readableBuffer = readableBuffer.Slice(consumed);
            }while (readableBuffer.Length > 0);

            Pipe.Reader.Advance(readableBuffer.End);
        }
예제 #3
0
        private void ParseData()
        {
            do
            {
                var awaitable = Pipe.Reader.ReadAsync();
                if (!awaitable.IsCompleted)
                {
                    // No more data
                    return;
                }

                var result         = awaitable.GetAwaiter().GetResult();
                var readableBuffer = result.Buffer;

                Http1Connection.Reset();

                if (!Http1Connection.TakeStartLine(readableBuffer, out var consumed, out var examined))
                {
                    ErrorUtilities.ThrowInvalidRequestLine();
                }
                Pipe.Reader.Advance(consumed, examined);

                result         = Pipe.Reader.ReadAsync().GetAwaiter().GetResult();
                readableBuffer = result.Buffer;

                if (!Http1Connection.TakeMessageHeaders(readableBuffer, out consumed, out examined))
                {
                    ErrorUtilities.ThrowInvalidRequestHeaders();
                }
                Pipe.Reader.Advance(consumed, examined);
            }while (true);
        }
예제 #4
0
        private void ParseRequest()
        {
            _http1Connection.Reset();

            var reader = new SequenceReader <byte>(_buffer);

            if (!_http1Connection.TakeStartLine(ref reader))
            {
                ErrorUtilities.ThrowInvalidRequestLine();
            }

            if (!_http1Connection.TakeMessageHeaders(ref reader, trailers: false))
            {
                ErrorUtilities.ThrowInvalidRequestHeaders();
            }
        }