Exemplo n.º 1
0
        private static Utf8Span ParseHeaderLine(Utf8Span headerString, out Utf8SpanPair header)
        {
            Utf8Span headerName;
            Utf8Span headerValue;

            //TODO: this will be simplified once we have TrySubstringTo/From accepting strings
            if (!headerString.TrySubstringTo((byte)':', out headerName))
            {
                throw new ArgumentException("headerString");
            }

            headerString.TrySubstringFrom((byte)':', out headerString);
            if (!headerString.IsEmpty)
            {
                headerString = headerString.Substring(1);
            }

            if (!headerString.TrySubstringTo((byte)'\r', out headerValue))
            {
                throw new ArgumentException("headerString");
            }

            headerString.TrySubstringFrom((byte)'\n', out headerString);
            if (!headerString.IsEmpty)
            {
                headerString = headerString.Substring(1);
            }

            header = new Utf8SpanPair(headerName, headerValue);

            return(headerString);
        }
Exemplo n.º 2
0
 internal Enumerator(Utf8Span originalHeaderString)
 {
     _originalHeaderString = originalHeaderString;
     _headerString         = _originalHeaderString;
     _current = new Utf8SpanPair();
 }