public static string SendRequest(string map, string moves) { var postForm = new PostForm(); postForm.AddParam("mapfile", map); postForm.AddParam("route", moves); return SendRequest(postForm); }
private static string SendRequest(PostForm postForm) { var request = CreateRequest(); var data = Encoding.UTF8.GetBytes(postForm.Content); request.ContentLength = data.Length; using(var requestStream = request.GetRequestStream()) requestStream.Write(data, 0, data.Length); var webResponse = request.GetResponse(); using(var streamReader = new StreamReader(webResponse.GetResponseStream())) return streamReader.ReadToEnd(); }
public ActionResult EditPost(PostForm postForm) { return View(); }
/// <summary> /// Executes the session. /// </summary> public void Run() { this._isRunning = true; reports = new ArrayList(); unitTestPostRequest = new PostForm(); unitTestGetRequest = new GetForm(); // Add proxy settings unitTestPostRequest.ProxySettings = this.Context.Proxy; unitTestGetRequest.ProxySettings = this.Context.Proxy; // http settings unitTestPostRequest.ClientSettings = this.Context.ProtocolProperties; unitTestGetRequest.ClientSettings = this.Context.ProtocolProperties; // set events for unit test requests unitTestPostRequest.EndHttp += new ResponseCallbackDelegate(UnitTestResult_EndHttp); unitTestGetRequest.EndHttp += new ResponseCallbackDelegate(UnitTestResult_EndHttp); HttpState state = new HttpState(); // the test sessin request of the safe request. state.TestSessionRequest = this.TestSession.SessionRequests[0]; state.SessionRequestId = 0; state.IsLastItem = true; ExecuteNextSafeRequest(state); }
// TODO: Still have to check this function, if is working as intended public void Run() { postRequest = new PostForm(); getRequest = new GetForm(); postRequest.EndHttp += new ResponseCallbackDelegate(httpResponse_EndHttp); getRequest.EndHttp += new ResponseCallbackDelegate(httpResponse_EndHttp); reports = new ArrayList(); UnitTestSession session = this.CurrentUnitTestSession; int availableTests = session.AvailableTests(); bool lastItem = false; // get tests count for (int i=0;i<session.UnitTestForms.Count;i++) { UnitTestItem testItem = session.UnitTestForms.GetByIndex(i); HtmlFormTag form = testItem.Form; #region Run each test in UnitTestItem // run each test in Form foreach (DictionaryEntry de in testItem.Tests) { Test test = (Test)de.Value; // apply test to form HtmlFormTag filledForm = ApplyTestToForm(test,form.CloneTag()); // set current test index testItem.SelectedTestIndex = testItem.Tests.IndexOfValue(test); // get reponse uri Uri uri = (Uri)this.CurrentUnitTestSession.SessionData.ResponseHeaderCollection["Response Uri"]; // resolve uri string url = UriResolver.ResolveUrl(uri,filledForm.Action); // process special fields // filledForm = parser.ProcessSpecialFields(filledForm); // convert to array list ArrayList al = parser.ConvertToArrayList(filledForm); // set posted data StringBuilder postDataBuffer = new StringBuilder(); postDataBuffer.Append("?"); for (int k=0;k<al.Count;k++) { postDataBuffer.Append(al[k]); postDataBuffer.Append("&"); } test.Arguments.PostData = postDataBuffer.ToString(); // set last item flag if ( availableTests == 1) { lastItem = true; } CookieManager cookieManager = new CookieManager(); CookieCollection cookies = cookieManager.GetCookies(new Uri(url)); if ( filledForm.Method.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "get" ) { getRequest.StartAsyncHttpGet( url, this.ProtocolProperties, al, cookies, testItem.Clone(), lastItem); } else { postRequest.StartAsyncHttpPost( url, this.ProtocolProperties, al, cookies, testItem.Clone(), lastItem); } availableTests--; } #endregion } }