示例#1
0
        /// <summary>
        /// Parses an HTTP form body.
        /// </summary>
        /// <param name="stream">The HTTP form body to parse.</param>
        /// <returns>The collection containing the parsed HTTP form body.</returns>
        public static async Task <IDictionary <string, StringValues> > ReadFormAsync(Stream stream, Encoding encoding, CancellationToken cancellationToken = new CancellationToken())
        {
            var reader = new FormReader(stream, encoding);

            var accumulator = new KeyValueAccumulator();
            var pair        = await reader.ReadNextPairAsync(cancellationToken);

            while (pair.HasValue)
            {
                accumulator.Append(pair.Value.Key, pair.Value.Value);
                pair = await reader.ReadNextPairAsync(cancellationToken);
            }

            return(accumulator.GetResults());
        }
示例#2
0
        /// <summary>
        /// Parses text from an HTTP form body.
        /// </summary>
        /// <param name="text">The HTTP form body to parse.</param>
        /// <returns>The collection containing the parsed HTTP form body.</returns>
        public static IDictionary <string, StringValues> ReadForm(string text)
        {
            var reader = new FormReader(text);

            var accumulator = new KeyValueAccumulator();
            var pair        = reader.ReadNextPair();

            while (pair.HasValue)
            {
                accumulator.Append(pair.Value.Key, pair.Value.Value);
                pair = reader.ReadNextPair();
            }

            return(accumulator.GetResults());
        }
示例#3
0
        /// <summary>
        /// Parses text from an HTTP form body.
        /// </summary>
        /// <param name="text">The HTTP form body to parse.</param>
        /// <returns>The collection containing the parsed HTTP form body.</returns>
        public static IDictionary <string, string[]> ReadForm(string text)
        {
            var reader = new FormReader(text);

            var accumulator = new KeyValueAccumulator <string, string>(StringComparer.OrdinalIgnoreCase);
            var pair        = reader.ReadNextPair();

            while (pair.HasValue)
            {
                accumulator.Append(pair.Value.Key, pair.Value.Value);
                pair = reader.ReadNextPair();
            }

            return(accumulator.GetResults());
        }
示例#4
0
        /// <summary>
        /// Parses an HTTP form body.
        /// </summary>
        /// <param name="stream">The HTTP form body to parse.</param>
        /// <returns>The collection containing the parsed HTTP form body.</returns>
        public static async Task<IDictionary<string, string[]>> ReadFormAsync(Stream stream, Encoding encoding, CancellationToken cancellationToken = new CancellationToken())
        {
            var reader = new FormReader(stream, encoding);

            var accumulator = new KeyValueAccumulator<string, string>(StringComparer.OrdinalIgnoreCase);
            var pair = await reader.ReadNextPairAsync(cancellationToken);
            while (pair.HasValue)
            {
                accumulator.Append(pair.Value.Key, pair.Value.Value);
                pair = await reader.ReadNextPairAsync(cancellationToken);
            }

            return accumulator.GetResults();
        }
示例#5
0
        /// <summary>
        /// Parses text from an HTTP form body.
        /// </summary>
        /// <param name="text">The HTTP form body to parse.</param>
        /// <returns>The collection containing the parsed HTTP form body.</returns>
        public static IDictionary<string, string[]> ReadForm(string text)
        {
            var reader = new FormReader(text);

            var accumulator = new KeyValueAccumulator<string, string>(StringComparer.OrdinalIgnoreCase);
            var pair = reader.ReadNextPair();
            while (pair.HasValue)
            {
                accumulator.Append(pair.Value.Key, pair.Value.Value);
                pair =  reader.ReadNextPair();
            }

            return accumulator.GetResults();
        }
示例#6
0
        /// <summary>
        /// Parses text from an HTTP form body.
        /// </summary>
        /// <param name="text">The HTTP form body to parse.</param>
        /// <returns>The collection containing the parsed HTTP form body.</returns>
        public static Dictionary<string, StringValues> ReadForm(string text)
        {
            var reader = new FormReader(text);

            var accumulator = new KeyValueAccumulator();
            var pair = reader.ReadNextPair();
            while (pair.HasValue)
            {
                accumulator.Append(pair.Value.Key, pair.Value.Value);
                pair = reader.ReadNextPair();
            }

            return accumulator.GetResults();
        }