Ejemplo n.º 1
0
 internal static void HandleHTTPError(Session oSession, SessionFlags flagViolation, bool bPoisonClientConnection, bool bPoisonServerConnection, string sMessage)
 {
     if (bPoisonClientConnection)
     {
         oSession.PoisonClientPipe();
     }
     if (bPoisonServerConnection)
     {
         oSession.PoisonServerPipe();
     }
     oSession.SetBitFlag(flagViolation, true);
     oSession["ui-backcolor"] = "LightYellow";
     Log.LogFormat("{0} - [#{1}] {2}", new object[] { "Fiddler.Network.ProtocolViolation", oSession.id.ToString(), sMessage });
     sMessage = "[ProtocolViolation] " + sMessage;
     if ((oSession["x-HTTPProtocol-Violation"] == null) || !oSession["x-HTTPProtocol-Violation"].Contains(sMessage))
     {
         Session session;
         (session = oSession)["x-HTTPProtocol-Violation"] = session["x-HTTPProtocol-Violation"] + sMessage;
     }
 }
Ejemplo n.º 2
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;
 }