예제 #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();
        }