utilSetResponseBody NO WORK

Q: No work !!! What is bad?

Thanks!

A:: This isn't a support forum for Fiddler or FiddlerCore; instead, ask questions here: https://groups.google.com/forum/#!forum/httpfiddler

You didn't say what is going wrong, but the most likely problem with the code below is that it doesn't set the bBufferResponse property to false inside a OnBeforeRequest or OnPeekAtResponseHeaders event handler. As a consequence, the body isn't modified until after it is already returned to the client application.

using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading;
using Fiddler;

namespace Demo
{
    class Program
    {
        static Proxy oSecureEndpoint;
        static string sSecureEndpointHostname = "localhost";
        static int iPort = 8800;

        private static string Ellipsize(string s, int iLen)
        {
            if (s.Length <= iLen) return s;
            return s.Substring(0, iLen - 3) + "...";
        }

        static void Main(string[] args)
        {

            FileStream fs;
            if (!File.Exists(System.IO.Path.GetTempPath()+"logSAVE.txt"))
            {fs = File.Create(System.IO.Path.GetTempPath()+"logSAVE.txt");}
            TextWriter tw = new StreamWriter("logSAVE.txt", true);
            List<Fiddler.Session> oAllSessions = new List<Fiddler.Session>();

            #region AttachEventListeners

            Fiddler.FiddlerApplication.BeforeResponse +=  delegate (Fiddler.Session oS)
            {
                if (oS.RequestHeaders.HTTPMethod.ToString() == "GET" || oS.RequestHeaders.HTTPMethod.ToString() == "POST")
                {
                    if (oS.responseCode.ToString() == "200")
                    {
                        if (oS.oResponse.headers.ExistsAndContains("Content-Type", "text/html"))
                        {

                            oS.utilDecodeResponse();
                            var oBody = System.Text.Encoding.UTF8.GetString(oS.responseBodyBytes);
                            oBody += "<h1>PROXYWEB</h1>";
                            oS.utilSetResponseBody(oBody + oS.oRequest.headers.ToString());

                        }
                    }
                }
            };
            #endregion AttachEventListeners

            Fiddler.CONFIG.IgnoreServerCertErrors = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;
            Fiddler.FiddlerApplication.Startup(iPort, oFCSF);

            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iPort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure endpoint listening on port {0}, using a HTTPS certificate for '{1}'", iPort, sSecureEndpointHostname);
            }
            bool bDone = false;
            while (!bDone)
            {

            }
        }  
    }
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License