Beispiel #1
0
        public ScrapeRequest GenerateSubmitRequest()
        {
            // Get
            var formValues = GetFormData();

            if (this.Method == "GET")
            {
                var action = this.Action;
                if (formValues.Count > 0)
                {
                    action = new Uri(action.ToString() + "?" + UrlEncodedFormData.GetQueryString(formValues));
                }
                return(new ScrapeRequest(action));
            }

            // POST
            if (this.Method == "POST")
            {
                return(new ScrapeRequest(Action, GetPostData(formValues)));
            }

            throw new ArgumentException("Unexpected method:" + this.Method);
        }
Beispiel #2
0
 /// <summary>
 /// Returns a friendly string containing all entries in the post data.
 /// </summary>
 public override string ToString()
 {
     return(this.ContentType + "\r\n" + UrlEncodedFormData.GetQueryString(this._postData));
 }
Beispiel #3
0
 /// <summary> Converts NameValueCollection to query string that can be appended to a base url. </summary>
 /// <remarks> Convenience short cut to FormUrlPostData.GetQueryString(...) </remarks>
 /// <param name="queryParameters">parameters to construct into a string</param>
 /// <returns>query string (without the leading '?')</returns>
 static public string ToQuery(NameValueCollection queryParameters)
 {
     return(UrlEncodedFormData.GetQueryString(queryParameters));
 }