示例#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);
        }
        private Utf8Span ReadStringValue()
        {
            _index++;
            var count = _index;
            do
            {
                while ((byte)_str[count] != '"')
                {
                    count++;
                }
                count++;
            } while (AreNumOfBackSlashesAtEndOfStringOdd(count - 2));

            var strLength = count - _index;
            var resultString = _str.Substring(_index, strLength - 1);
            _index += strLength;

            SkipEmpty();
            return resultString;
        }