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); }
/// <summary> /// Fluent method for parsing a query string into NameValueCollection /// by calling FormUrlPostData.GetFormCollection(..); /// </summary> static public NameValueCollection GetFormParameters(this string queryString) { return(UrlEncodedFormData.GetFormCollection(queryString)); }
/// <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)); }
/// <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)); }