Ejemplo n.º 1
0
        public bool Read(PipeStream stream, Cookies cookies)
        {
            string lineData;

            while (stream.TryReadWith(HeaderTypeFactory.LINE_BYTES, out lineData))
            {
                if (string.IsNullOrEmpty(lineData))
                {
                    return(true);
                }
                else
                {
                    ReadOnlySpan <Char> line = lineData;
                    if (line[0] == 'C' && line[5] == 'e' && line[1] == 'o' && line[2] == 'o' && line[3] == 'k' && line[4] == 'i')
                    {
                        HttpParse.AnalyzeCookie(line.Slice(8, line.Length - 8), cookies);
                    }
                    else
                    {
                        Tuple <string, string> result = HttpParse.AnalyzeHeader(line);
                        this[result.Item1] = result.Item2;
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool Read(PipeStream stream, Cookies cookies)
        {
            IndexOfResult index = stream.IndexOf(HeaderType.LINE_BYTES);

            while (index.End != null)
            {
                if (index.Length == 2)
                {
                    stream.ReadFree(2);
                    return(true);
                }
                else
                {
                    ReadOnlySpan <Char> line = HttpParse.ReadCharLine(index);
                    stream.ReadFree(index.Length);
                    if (line[0] == 'C' && line[5] == 'e' && line[1] == 'o' && line[2] == 'o' && line[3] == 'k' && line[4] == 'i')
                    {
                        HttpParse.AnalyzeCookie(line.Slice(8, line.Length - 8), cookies);
                    }
                    else
                    {
                        Tuple <string, string> result = HttpParse.AnalyzeHeader(line);
                        Add(result.Item1, result.Item2);
                    }
                }
                index = stream.IndexOf(HeaderType.LINE_BYTES);
            }
            return(false);
        }
Ejemplo n.º 3
0
            public bool Import(ReadOnlySpan <byte> bytes, PipeStream stream, Header header, Cookies cookie)
            {
                Span <char> bufferSpan = new Span <char>(Buffer);

                for (int i = 0; i < bytes.Length; i++)
                {
                    byte b = bytes[i];
                    Char c = (char)b;
                    bufferSpan[Count] = c;
                    Count++;
                    if (bufferSpan[Count - 1] == '\n' && bufferSpan[Count - 2] == '\r')
                    {
                        stream.ReadFree(Count);
                        if (Count == 2)
                        {
                            EmptyLine = true;
                            return(true);
                        }
                        string value = new string(bufferSpan.Slice(Offset, Count - Offset - 2));
                        header[Name] = value;
                        if (Name[0] == 'C' && Name[5] == 'e' && Name[1] == 'o' && Name[2] == 'o' && Name[3] == 'k' && Name[4] == 'i')
                        {
                            HttpParse.AnalyzeCookie(value, cookie);
                        }
                        Name      = null;
                        Offset    = 0;
                        Count     = 0;
                        EmptyLine = false;
                        return(true);
                    }
                    if (c == ':')
                    {
                        if (Name == null)
                        {
                            Name   = new string(bufferSpan.Slice(Offset, Count - Offset - 1));
                            Offset = (short)(Count);
                        }
                    }
                    else
                    {
                        if (Name != null)
                        {
                            if (c == ' ')
                            {
                                Offset++;
                            }
                        }
                    }
                }
                return(false);
            }
Ejemplo n.º 4
0
        public bool Read(PipeStream stream, Cookies cookies)
        {
            Span <char> lineData;

            while (stream.ReadLine(out lineData))
            {
                if (lineData.Length == 0)
                {
                    return(true);
                }
                else
                {
                    ReadOnlySpan <Char>    line   = lineData;
                    Tuple <string, string> result = HttpParse.AnalyzeHeader(line);
                    this[result.Item1] = result.Item2;
                    if (line[0] == 'C' && line[5] == 'e' && line[1] == 'o' && line[2] == 'o' && line[3] == 'k' && line[4] == 'i')
                    {
                        HttpParse.AnalyzeCookie(line.Slice(8, line.Length - 8), cookies);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        public bool Read(PipeStream stream, Cookies cookies)
        {
            Span <char> lineData;

            while (stream.ReadLine(out lineData))
            {
                if (lineData.Length == 0)
                {
                    return(true);
                }
                else
                {
                    ReadOnlySpan <Char>    line   = lineData;
                    Tuple <string, string> result = HttpParse.AnalyzeHeader(line);
                    this[result.Item1] = result.Item2;
                    if (line.StartsWith(new ReadOnlySpan <char>(new [] { 'c', 'o', 'o', 'k', 'i', 'e' }), StringComparison.OrdinalIgnoreCase))
                    {
                        HttpParse.AnalyzeCookie(line.Slice(8, line.Length - 8), cookies);
                    }
                }
            }
            return(false);
        }