Beispiel #1
0
        private static void CheckDispositionTypeFormat(string dispositionType, string parameterName)
        {
            if (string.IsNullOrEmpty(dispositionType))
            {
                throw new ArgumentException(SR.net_http_argument_empty_string, parameterName);
            }
            string dispositionType1;

            if (ContentDispositionHeaderValue.GetDispositionTypeExpressionLength(dispositionType, 0, out dispositionType1) == 0 || dispositionType1.Length != dispositionType.Length)
            {
                throw new FormatException(SR.Format((IFormatProvider)CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, (object)dispositionType));
            }
        }
Beispiel #2
0
        internal static int GetDispositionTypeLength(
            string input,
            int startIndex,
            out object parsedValue)
        {
            parsedValue = (object)null;
            if (string.IsNullOrEmpty(input) || startIndex >= input.Length)
            {
                return(0);
            }
            string dispositionType  = (string)null;
            int    expressionLength = ContentDispositionHeaderValue.GetDispositionTypeExpressionLength(input, startIndex, out dispositionType);

            if (expressionLength == 0)
            {
                return(0);
            }
            int startIndex1 = startIndex + expressionLength;
            int index       = startIndex1 + HttpRuleParser.GetWhitespaceLength(input, startIndex1);
            ContentDispositionHeaderValue dispositionHeaderValue = new ContentDispositionHeaderValue();

            dispositionHeaderValue._dispositionType = dispositionType;
            if (index < input.Length && input[index] == ';')
            {
                int startIndex2         = index + 1;
                int nameValueListLength = NameValueHeaderValue.GetNameValueListLength(input, startIndex2, ';', (ObjectCollection <NameValueHeaderValue>)dispositionHeaderValue.Parameters);
                if (nameValueListLength == 0)
                {
                    return(0);
                }
                parsedValue = (object)dispositionHeaderValue;
                return(startIndex2 + nameValueListLength - startIndex);
            }
            parsedValue = (object)dispositionHeaderValue;
            return(index - startIndex);
        }