Para
Para

Reputation: 2082

utilSetResponseBody FiddlerCore doesn't do anything

oSession.utilDecodeResponse();
            body = oSession.GetResponseBodyAsString();

            if (body.Contains("<body>"))
            {
                oSession.utilSetResponseBody(body.Replace("<body>", "<body><script src='a.js' type='text/javascript'/>"));

This is the exact code that runs inside my

private void FiddlerApplication_BeforeResponse(Session oSession)
    {

event.
I can reach it with the debugger and everthing goes fine but in Internet Explorer when I select "View Source" nothing is changed.
Does anyone know what I am doing wrong? Thanks

Upvotes: 0

Views: 3255

Answers (1)

Vasilii Alchakov
Vasilii Alchakov

Reputation: 99

Please take a look at this link Fiddler's Streaming Mode

So you need to add

FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oSession)
{
    oSession.bBufferResponse = true;                
};

Also please try to use

FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oSession)
{
    oSession.utilDecodeResponse();
    String oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
    oBody = oBody.Replace("<body>", "<body><script src='a.js' type='text/javascript'/>");
    oSession.utilSetResponseBody(oBody);
};

The problem is body = oSession.GetResponseBodyAsString(); returns an empty string for me. Hope this helps.

Upvotes: 8

Related Questions