示例#1
0
        /// <summary>
        /// Reads a token or quoted-string value from the header.
        /// </summary>
        /// <returns>The token or quoted-string value that was read from the header.</returns>
        private HttpHeaderValueLexer ReadNextTokenOrQuotedString()
        {
            int    index = this.startIndexOfNextItem;
            bool   isQuotedString;
            string nextValue = HttpUtils.ReadTokenOrQuotedStringValue(this.httpHeaderName, this.httpHeaderValue, ref index, out isQuotedString, message => new ODataException(message));

            // Instead of testing whether result is null or empty, we check to see if the index have moved forward because we can encounter the empty quoted string "".
            if (index == this.startIndexOfNextItem)
            {
                throw new ODataException(Strings.HttpHeaderValueLexer_FailedToReadTokenOrQuotedString(this.httpHeaderName, this.httpHeaderValue, this.startIndexOfNextItem));
            }

            if (isQuotedString)
            {
                string original = this.httpHeaderValue.Substring(this.startIndexOfNextItem, index - this.startIndexOfNextItem);
                return(new HttpHeaderQuotedString(this.httpHeaderName, this.httpHeaderValue, nextValue, original, index));
            }

            return(new HttpHeaderToken(this.httpHeaderName, this.httpHeaderValue, nextValue, index));
        }