public void Setup() { var liveaspnetRequestBytes = Encoding.UTF8.GetBytes(liveaspnetRequest); var pipelinedRequests = string.Concat(Enumerable.Repeat(plaintextRequest, 16)); _plainTextPipelinedBuffer = ReadableBuffer.Create(Encoding.UTF8.GetBytes(pipelinedRequests)); _plainTextBuffer = ReadableBuffer.Create(Encoding.UTF8.GetBytes(plaintextRequest)); _liveAspNetBuffer = ReadableBuffer.Create(liveaspnetRequestBytes); // Split the liveaspnetRequest across 3 byte[] var remaining = liveaspnetRequestBytes.Length; var consumed = 0; var liveAspNetBuffers = new List <byte[]>(); var chunk = remaining / 3; while (remaining > 0) { var bytes = new byte[Math.Min(chunk, remaining)]; Buffer.BlockCopy(liveaspnetRequestBytes, consumed, bytes, 0, bytes.Length); consumed += bytes.Length; remaining -= bytes.Length; liveAspNetBuffers.Add(bytes); } _liveAspNetMultiBuffer = BufferUtilities.CreateBuffer(liveAspNetBuffers.ToArray()); }
public void ToSpanOnReadableBufferSingleSpan() { byte[] data = { 0, 1, 2, 3, 4, 5, 6, 7 }; var readable = BufferUtilities.CreateBuffer(data); var span = readable.ToSpan(); Assert.True(readable.IsSingleSpan); Assert.Equal(span.Length, data.Length); }
public void ParseRequestLineSplitBufferWithoutNewLineDoesNotUpdateConsumed() { var parser = CreateParser(Mock.Of <IKestrelTrace>()); var buffer = BufferUtilities.CreateBuffer("GET ", "/"); var requestHandler = new RequestHandler(); var result = parser.ParseRequestLine(requestHandler, buffer, out var consumed, out var examined); Assert.False(result); Assert.Equal(buffer.Start, consumed); Assert.Equal(buffer.End, examined); }
public void ToSpanOnReadableBufferMultiSpan() { byte[] data1 = { 0, 1, 2 }; byte[] data2 = { 3, 4, 5 }; byte[] data3 = { 6, 7, 8 }; var readable = BufferUtilities.CreateBuffer(data1, data2, data3); var span = readable.ToSpan(); Assert.False(readable.IsSingleSpan); Assert.Equal(span.Length, data1.Length + data2.Length + data3.Length); }
public void ParseRequestLineSplitBufferWithoutNewLineDoesNotUpdateConsumed() { HttpParser parser = new HttpParser(); ReadOnlyBuffer <byte> buffer = BufferUtilities.CreateBuffer("GET ", "/"); RequestHandler requestHandler = new RequestHandler(); bool result = parser.ParseRequestLine(requestHandler, buffer, out SequencePosition consumed, out SequencePosition examined); Assert.False(result); Assert.Equal(buffer.Slice(consumed).Length, buffer.Length); Assert.True(buffer.Slice(examined).IsEmpty); }
public override ReadOnlySequence <T> CreateWithContent(T[] data) { var segments = new List <T[]>(); segments.Add(System.Array.Empty <T>()); foreach (var b in data) { segments.Add(new[] { b }); segments.Add(System.Array.Empty <T>()); } return(BufferUtilities.CreateBuffer <T>(segments.ToArray())); }
public void ParseRequestLineSplitBufferWithoutNewLineDoesNotUpdateConsumed() { HttpParser parser = new HttpParser(); ReadOnlyBuffer <byte> buffer = BufferUtilities.CreateBuffer("GET ", "/"); RequestHandler requestHandler = new RequestHandler(); bool result = parser.ParseRequestLine(requestHandler, buffer, out Position consumed, out Position examined); Assert.False(result); Assert.Equal(buffer.Start, consumed); Assert.Equal(buffer.End, examined); }
public override ReadOnlySequence <T> CreateWithContent(T[] data) { return(BufferUtilities.CreateBuffer <T>(data)); }
public override ReadOnlySequence <T> CreateOfSize(int size) { return(BufferUtilities.CreateBuffer <T>(size)); }
public void Setup() { _readOnlyBuffer = BufferUtilities.CreateBuffer(Enumerable.Range(100, 200).ToArray()); }