Exemple #1
0
        /// <summary>
        /// Initializes the request info post data.
        /// </summary>
        protected virtual void IntializeRequestInfoPostData(HttpRequest httpRequest)
        {
            if (httpRequest != null)
            {
                // TODO: test this case
                // When a post back event occurred "httpRequest.ContentType" contains ContentType of request
                // In other cases the "httpRequest.ContentType" is empty and we shouldn't use this property
                if (!string.IsNullOrEmpty(httpRequest.ContentType))
                {
                    RequestInfo.SetContentType(httpRequest.ContentType);
                }

                RequestInfo.InputStream = httpRequest.InputStream;


                // Get posted form data string
                string httpRequestMethod = httpRequest.HttpMethod;

                if (WebMethods.IsMethod(httpRequestMethod, WebMethods.DefaultMethods.POST))
                {
                    RequestInfo.PostDataString = httpRequest.Form.ToString();

                    // Some web sites encodes the url, and we need to decode it.
                    //RequestInfo.PostDataString = HttpUtility.HtmlDecode(RequestInfo.PostDataString);

                    // Since V5.5
                    // The text should be decoded before any use
                    RequestInfo.PostDataString = UnicodeUrlDecoder.UrlDecode(RequestInfo.PostDataString);

                    // BUG: not working with (#) and (&) characters
                    //RequestInfo.PostDataString = HttpUtility.UrlDecode(RequestInfo.PostDataString);
                }
                else
                {
                    RequestInfo.PostDataString = "";
                }
            }
            else
            {
                RequestInfo.PostDataString = "";
            }


            // If requested method is GET
            if (WebMethods.IsMethod(RequestInfo.RequestMethod, WebMethods.DefaultMethods.GET))
            {
                // Apply filter for ASP.NET pages

                // Change requested url by posted data
                RequestInfo.RequestUrl = UrlBuilder.AppendAntoherQueries(RequestInfo.RequestUrl, RequestInfo.PostDataString);
            }
        }