public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken) { var peek = input.PeekUntil(x => x.Count == _connectLength); Content = new string(peek.ToArray()); return(Parent); }
public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken) { var peek = input.PeekUntil(x => x.Last() == '\n').ToArray(); Value = new string(peek); return(Parent); }
public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken) { var peek = input.PeekUntil(x => x.Last() == ':'); Name = new string(peek.Take(peek.Count - 1).ToArray()); input.BacktrackPeek(1); return(Parent); }
public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken) { if (!input.Peekable()) { return(null); } return(new MessageBody(this)); }
public void Seek_should_remove_from_buffer() { var chars = Autofixture.CreateMany <char>(10).ToList(); var enumerator = chars.GetEnumerator(); var seeker = new BufferedSeeker(enumerator); // Act seeker.Seek(2); var result = seeker.Peek(); // Assert result.Should().Be(chars.Skip(2).First()); seeker.PeakIndex.Should().Be(3); }
public void Backtrack_peek_should_move_peek_index_backwards() { var chars = Autofixture.CreateMany <char>(10).ToList(); var enumerator = chars.GetEnumerator(); var seeker = new BufferedSeeker(enumerator); // Act seeker.Peek(); seeker.Peek(); seeker.BacktrackPeek(2); var result = seeker.Peek(); // Assert result.Should().Be(chars.First()); seeker.PeakIndex.Should().Be(1); }
public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken) { switch (lastToken) { case HeaderField token: Headers.Add(token.Name, token.Value); ProcessHeaders(token.Name, token.Value); break; } var peek = input.PeekUntil(x => x.Count == 2); input.BacktrackPeek(2); if (peek.First() == '\r' && peek.Last() == '\n') { return(Parent); } return(new HeaderField(this)); }
public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken) { switch (lastToken) { case MessageBodyHeader _: return(new HeaderFieldName(this)); case HeaderFieldName token: Name = token.Name; return(new HeaderFieldSeparator(this)); case HeaderFieldSeparator token: return(new HeaderFieldValue(this)); case HeaderFieldValue token: Value = token.Value; break; } return(Parent); }
public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken) { switch (lastToken) { case MessageStream token: return(new MessageBodyHeader(this)); case MessageBodyHeader token: MessageBodyHeader = token; return(new MessageBodySeparator(this)); case MessageBodySeparator token: return(new MessageBodyContent(this, MessageBodyHeader.ContentLength)); case MessageBodyContent token: ContentMessageBody = token; return(new MessageBodyCompleted(this)); case MessageBodyCompleted token: break; } return(Parent); }
public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken) { return(Parent); }
public abstract ParsingToken Process(BufferedSeeker input, ParsingToken lastToken);
public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken) { input.PeekUntil(x => x.Count == 2); return(Parent); }