Пример #1
0
 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 entry in oNewFlags)
         {
             session.oFlags[(string) entry.Key] = oNewFlags[(string) entry.Key];
         }
     }
     session.ExecuteUponAsyncRequest();
     return session;
 }