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(); } }
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); }
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); }
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(); } }