internal static int GetProductInfoLength(string input, int startIndex, out ProductInfoHeaderValue parsedValue)
{
Debug.Assert(startIndex >= 0);
parsedValue = null;
if (string.IsNullOrEmpty(input) || (startIndex >= input.Length))
{
return 0;
}
int current = startIndex;
// Caller must remove leading whitespace.
string comment = null;
ProductHeaderValue product = null;
if (input[current] == '(')
{
int commentLength = 0;
if (HttpRuleParser.GetCommentLength(input, current, out commentLength) != HttpParseResult.Parsed)
{
return 0;
}
comment = input.Substring(current, commentLength);
current = current + commentLength;
current = current + HttpRuleParser.GetWhitespaceLength(input, current);
}
else
{
// Trailing whitespace is removed by GetProductLength().
int productLength = ProductHeaderValue.GetProductLength(input, current, out product);
if (productLength == 0)
{
return 0;
}
current = current + productLength;
}
parsedValue = new ProductInfoHeaderValue();
parsedValue._product = product;
parsedValue._comment = comment;
return current - startIndex;
}