Esempio n. 1
0
        public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken)
        {
            var peek = input.PeekUntil(x => x.Count == _connectLength);

            Content = new string(peek.ToArray());
            return(Parent);
        }
Esempio n. 2
0
        public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken)
        {
            var peek = input.PeekUntil(x => x.Last() == '\n').ToArray();

            Value = new string(peek);
            return(Parent);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken)
 {
     if (!input.Peekable())
     {
         return(null);
     }
     return(new MessageBody(this));
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
 public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken)
 {
     return(Parent);
 }
Esempio n. 11
0
 public abstract ParsingToken Process(BufferedSeeker input, ParsingToken lastToken);
Esempio n. 12
0
 public override ParsingToken Process(BufferedSeeker input, ParsingToken lastToken)
 {
     input.PeekUntil(x => x.Count == 2);
     return(Parent);
 }