public Session SendRequest(HTTPRequestHeaders oHeaders, byte[] arrRequestBodyBytes, StringDictionary oNewFlags, EventHandler <StateChangeEventArgs> onStateChange) { if (oHeaders.ExistsAndContains("Fiddler-Encoding", "base64")) { oHeaders.Remove("Fiddler-Encoding"); if (!Utilities.IsNullOrEmpty(arrRequestBodyBytes)) { arrRequestBodyBytes = Convert.FromBase64String(Encoding.ASCII.GetString(arrRequestBodyBytes)); if (oNewFlags == null) { oNewFlags = new StringDictionary(); } oNewFlags["x-Builder-FixContentLength"] = "CFE-required"; } } if (oHeaders.Exists("Fiddler-Host")) { if (oNewFlags == null) { oNewFlags = new StringDictionary(); } oNewFlags["x-OverrideHost"] = oHeaders["Fiddler-Host"]; oNewFlags["X-IgnoreCertCNMismatch"] = "Overrode HOST"; oHeaders.Remove("Fiddler-Host"); } if (oNewFlags != null && oNewFlags.ContainsKey("x-Builder-FixContentLength")) { if (arrRequestBodyBytes != null && !oHeaders.ExistsAndContains("Transfer-Encoding", "chunked")) { if (!Utilities.HTTPMethodAllowsBody(oHeaders.HTTPMethod) && arrRequestBodyBytes.Length == 0) { oHeaders.Remove("Content-Length"); } else { oHeaders["Content-Length"] = arrRequestBodyBytes.LongLength.ToString(); } } else { oHeaders.Remove("Content-Length"); } } Session session = new Session((HTTPRequestHeaders)oHeaders.Clone(), arrRequestBodyBytes); session.SetBitFlag(SessionFlags.RequestGeneratedByFiddler, true); if (onStateChange != null) { session.OnStateChanged += onStateChange; } if (oNewFlags != null && oNewFlags.Count > 0) { foreach (DictionaryEntry dictionaryEntry in oNewFlags) { session.oFlags[(string)dictionaryEntry.Key] = oNewFlags[(string)dictionaryEntry.Key]; } } session.ExecuteUponAsyncRequest(); return(session); }
public Session SendRequest(HTTPRequestHeaders oHeaders, byte[] arrRequestBodyBytes, StringDictionary oNewFlags) { Session session = new Session((HTTPRequestHeaders)oHeaders.Clone(), arrRequestBodyBytes); session.SetBitFlag(SessionFlags.RequestGeneratedByFiddler, true); if ((oNewFlags != null) && (oNewFlags.Count > 0)) { foreach (DictionaryEntry entry in oNewFlags) { session.oFlags[(string)entry.Key] = oNewFlags[(string)entry.Key]; } } ThreadPool.UnsafeQueueUserWorkItem(new WaitCallback(session.Execute), null); return(session); }
private bool actSendRequestFromWizard(bool bBreakRequest) { this.txtBuilderURL.Text = this.txtBuilderURL.Text.Trim(); if (!this.txtBuilderURL.Text.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { if (this.txtBuilderURL.Text.Contains("://")) { MessageBox.Show("Only HTTP:// and HTTPS:// URLs are supported.\n\nInvalid URI: " + this.txtBuilderURL.Text, "Invalid URI"); return(false); } this.txtBuilderURL.Text = "http://" + this.txtBuilderURL.Text; } bool flag = this.txtBuilderURL.Text.Contains("#"); int result = 0; int num2 = 10; if (flag) { string s = string.Empty; string str = frmPrompt.GetUserString("Sequential Requests Starting At", "All instances of the # character will be replaced with a consecutive integer starting at: ", "0", true); if (str == null) { flag = false; } if (flag) { s = frmPrompt.GetUserString("Sequential Requests Ending At", "End at: ", "10", true); if (s == null) { flag = false; } } if (flag && (!int.TryParse(str, out result) || !int.TryParse(s, out num2))) { flag = false; } } try { StringBuilder builder; Label_0108: builder = new StringBuilder(0x400); string text = this.txtBuilderURL.Text; if (flag) { text = text.Replace("#", result.ToString()); } builder.AppendFormat("{0} {1} {2}\r\n", this.cbxBuilderMethod.Text, text, this.cbxBuilderHTTPVersion.Text); builder.Append(this.txtBuilderRequestHeaders.Text.Trim()); builder.Append("\r\n\r\n"); HTTPRequestHeaders oHeaders = Parser.ParseRequest(builder.ToString()); builder = null; byte[] bytes = Utilities.getEntityBodyEncoding(oHeaders, null).GetBytes(this.txtBuilderRequestBody.Text); string str4 = this.txtBuilderURL.Text; int index = str4.IndexOf("//", StringComparison.Ordinal); if (index > -1) { str4 = str4.Substring(index + 2); } int length = str4.IndexOfAny(new char[] { '/', '?' }); if (length > -1) { str4 = str4.Substring(0, length).ToLower(); } oHeaders["Host"] = str4; if (flag && oHeaders.ExistsAndContains("Host", "#")) { oHeaders["Host"] = oHeaders["Host"].Replace("#", result.ToString()); } if ((this.cbFixContentLength.Checked && (oHeaders.Exists("Content-Length") || (bytes.Length > 0))) && !oHeaders.ExistsAndContains("Transfer-Encoding", "chunked")) { oHeaders["Content-Length"] = bytes.Length.ToString(); } this.txtBuilderRequestHeaders.Text = oHeaders.ToString(false, false); Session session = new Session((HTTPRequestHeaders)oHeaders.Clone(), bytes); session.SetBitFlag(SessionFlags.RequestGeneratedByFiddler, true); session.oFlags["x-From-Builder"] = "true"; bool flag2 = this.cbSelectBuilderResult.Checked; if (bBreakRequest) { session.oFlags["x-breakrequest"] = "Builder"; flag2 = true; } if (flag) { if (session.oRequest.headers.ExistsAndContains("Referer", "#")) { session.oRequest["Referer"] = session.oRequest["Referer"].Replace("#", result.ToString()); } } else if (flag2) { session.oFlags["x-Builder-Inspect"] = "1"; } if (this.cbAutoAuthenticate.Checked) { session.oFlags["x-AutoAuth"] = "(default)"; } if (this.cbFollowRedirects.Checked) { session.oFlags["x-Builder-MaxRedir"] = FiddlerApplication.Prefs.GetInt32Pref("fiddler.requestbuilder.followredirects.max", 10).ToString(); } ThreadPool.UnsafeQueueUserWorkItem(new WaitCallback(session.Execute), null); if (flag && (result < num2)) { result++; goto Label_0108; } return(true); } catch (Exception exception) { FiddlerApplication.DoNotifyUser(exception.Message, "Custom Request Failed"); return(false); } }