public void AddInSteps() { var slize = CreateSlice(@"GET / HTTP/1.1 Connection: Keep-Alive HOST: localhost Content-Length: 0 "); slize.Count = 1; HttpParser parser = new HttpParser(); Assert.Null(parser.Parse(slize)); Assert.Equal(0, slize.Position); slize.Count = 10; Assert.Null(parser.Parse(slize)); Assert.Equal(0, slize.Position); //first line slize.Count = 16; Assert.Null(parser.Parse(slize)); Assert.Equal(16, slize.Position); slize.Count = 78 - 16; var request = parser.Parse(slize); Assert.Equal("Keep-Alive", request.Headers["Connection"].Value); Assert.Equal("localhost", request.Headers["HOST"].Value); Assert.Equal("0", request.Headers["Content-Length"].Value); }
public async Task ParserCanParseSampleMarkup() { //arrange HttpParser parser = new HttpParser(); IEnumerable <Match> result = await parser.Parse(File.ReadAllText("Integration//SampleMarkup.html")); //act result.ToList().ForEach(r => Console.WriteLine(r.Value)); //assert // yeah yeah could assert a known match collection length. }
public void BasicDoc() { var slize = CreateSlice(@"GET / HTTP/1.1 Connection: Keep-Alive HOST: localhost Content-Length: 0 "); HttpParser parser = new HttpParser(); var request = parser.Parse(slize); Assert.Equal("Keep-Alive", request.Headers["Connection"].Value); Assert.Equal("localhost", request.Headers["HOST"].Value); Assert.Equal("0", request.Headers["Content-Length"].Value); }
/// <summary> /// Will continue the parsing until nothing more can be parsed. /// </summary> /// <param name="buffer">buffer to parse</param> /// <param name="offset">where to start in the buffer</param> /// <param name="length">number of bytes to process.</param> /// <returns>Position where parser stopped parsing.</returns> /// <exception cref="ParserException">Parsing failed.</exception> public int Parse(byte[] buffer, int offset, int length) { return(_parser.Parse(buffer, offset, length)); }