/// <summary> /// Called when no OnSubmit event is raised. /// </summary> /// <param name="sender"> The sender object.</param> /// <param name="e"> The FormHeuriscticEventArgs.</param> private void navForm_FormHeuristicEvent(object sender, FormHeuristicArgs e) { FormConverter converter = new FormConverter(); HtmlFormTag form = converter.AddPostDataValues(e.FormTag, e.PostData); if ( form.Action.Length == 0 ) { form.Action = e.SiteUri.Scheme + "://" + e.SiteUri.Authority + e.SiteUri.AbsolutePath; } RequestPostEventArgs postArgs = new RequestPostEventArgs(); // TODO: Check of Method is POST or GET // Just post postArgs.InspectorRequestAction = InspectorAction.WebBrowserPost; postArgs.Form = form; postArgs.Method = form.Method; postArgs.PostData = Encoding.UTF8.GetBytes(e.PostData); postArgs.CurrentUri = e.SiteUri; // request this.InspectorStartPostEvent(this, postArgs); // Add Easy Test options //this.RunQuickTests(postArgs); }
/// <summary> /// Called when a OnSubmit event is raised. /// </summary> /// <param name="sender"> The sender object.</param> /// <param name="e"> The FormConvertionEventArgs.</param> private void navForm_FormConvertionEvent(object sender, FormConvertionArgs e) { FormConverter converter = new FormConverter(); HtmlFormTag form = converter.ConvertToHtmlFormTag(e.FormElement, e.SiteUri); form = converter.AddPostDataValues(form, e.PostData); // Just post RequestPostEventArgs postArgs = new RequestPostEventArgs(); postArgs.InspectorRequestAction = InspectorAction.WebBrowserPost; postArgs.Form = form; postArgs.Method = form.Method; postArgs.PostData = Encoding.UTF8.GetBytes(e.PostData); postArgs.CurrentUri = e.SiteUri; this.InspectorStartPostEvent(this, postArgs); // Add Quick Test options //this.RunQuickTests(postArgs); }
/// <summary> /// Starts the post event for the inspector. /// </summary> /// <param name="sender"> The sender object.</param> /// <param name="e"> The RequestPostEventArgs.</param> private void InspectorStartPostEvent(object sender, RequestPostEventArgs e) { // TODO: Set options here // TODO: Have options for AtLeastOneRadioChecked, AtLeastOneCheckbox, AllCheckboxesChecked ArrayList al = parser.GetArrayList(e.Form); Uri uri = e.CurrentUri; // Resolve url string formUri = UriResolver.ResolveUrl(uri, e.Form.Action); // get cookies CookieCollection cookies = null; cookies = postForm.CookieManager.GetCookies(new Uri(formUri)); // navigate ie System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int k=0;k<al.Count;k++) { sb.Append(al[k]); sb.Append("&"); } if ((e.InspectorRequestAction == InspectorAction.UserPost) || (e.InspectorRequestAction == InspectorAction.InspectorRedirection)) { navForm.PostForm(formUri,e.PostData,cookies, e.InspectorRequestAction); } // Allows the browser to request first. if (!AllowBrowserFirst) { // Save Web Session AddSessionPost(formUri, Encoding.UTF8.GetString(e.PostData), e.Form, cookies); // Set Inspector State InspectorState = GBInspectorState.Requesting; // Update Progress Bar StartProgressBarEvent(this,new ProgressBarControlEventArgs("Sending post...")); // Execute Post request GetPostRequest(formUri,al,this.CurrentResponseBuffer, cookies, e.Form); } }
/// <summary> /// Request Post Event from Form Editor. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void formeditor_RequestPostEvent(object sender,RequestPostEventArgs e) { if ( e.Form.Action == String.Empty ) { MessageBox.Show("Not a postable form. Check source code for any scripting use.\r\nForm name:" + e.Form.Name,AppLocation.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Uri uri = (Uri)CurrentResponseBuffer.ResponseHeaderCollection["Response Uri"]; string formUri = UriResolver.ResolveUrl(uri,e.Form.Action); // FormConverter formConverter = new FormConverter(); if ( e.Method.ToLower() == "post" ) { e.PostData = Encoding.UTF8.GetBytes(parser.GetString(e.Form)); e.InspectorRequestAction = InspectorAction.UserPost; e.CurrentUri = new Uri(formUri); this.InspectorStartPostEvent(this, e); } else { // Get Request RequestGetEventArgs requestArgs = new RequestGetEventArgs(); requestArgs.InspectorRequestAction = InspectorAction.UserGet; requestArgs.Url = formUri; requestArgs.Form = e.Form; this.InspectorStartGetEvent(this, requestArgs); } // Add Easy Test options //this.RunQuickTests(e); }
/// <summary> /// Submit form as a POST. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuSubmitPost_Click(object sender, System.EventArgs e) { //1: Get the form tag and send HtmlFormTag formtag=tree.SelectedNode.BaseHtmlTag as HtmlFormTag; RequestPostEventArgs args = new RequestPostEventArgs(); args.Form = formtag.CloneTag(); args.Method="post"; RequestPostEvent(this,args); }
/// <summary> /// Submit form. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void menuItem3_Click(object sender, System.EventArgs e) { // Get the form tag and send HtmlFormTag formtag = tree.SelectedNode.BaseHtmlTag as HtmlFormTag; // post form RequestPostEventArgs args = new RequestPostEventArgs(); args.Method=formtag.Method; args.Form=formtag.CloneTag(); RequestPostEvent(this,args); }