BF2Statistics.Web.HttpRequest.GetFormUrlEncodedPostVars C# (CSharp) Method

GetFormUrlEncodedPostVars() public method

If a form was submitted using the POST http method, and the entity body is UrlFormEncoded, the post variables can be fetched from this method
public GetFormUrlEncodedPostVars ( ) : string>.Dictionary
return string>.Dictionary
        public Dictionary<string, string> GetFormUrlEncodedPostVars()
        {
            // No post data, or processed already?
            if (!Request.HasEntityBody || PostVars != null)
            {
                // Initialize empty Dic
                if (PostVars == null)
                    PostVars = new Dictionary<string, string>(0);

                return PostVars;
            }

            // Always wrap handling user data in a Try-Catch
            try
            {
                using (StreamReader reader = new StreamReader(Request.InputStream, Encoding.UTF8))
                {
                    string[] rawParams = reader.ReadToEnd().Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
                    PostVars = new Dictionary<string, string>(rawParams.Length);
                    foreach (string field in rawParams)
                    {
                        // Convert to Key/Value
                        string[] pair = field.Split(new[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries);

                        // If we dont have a key/pair, skip
                        if (pair.Length != 2)
                            continue;

                        PostVars[pair[0]] = Uri.UnescapeDataString(pair[1]);
                    }
                }
            }
            catch { }

            return PostVars;
        }