Wednesday, 11 December 2013

Altering the HTTP response using Fiddler

Should you ever have the need to change the http response to a web server, then please note in the latest version of Fiddler it's actually possible to do this without having to hack the CustomRules.js file that the Fiddler training videos and documentation tell you about.

You can simply set up an AutoResponder tab rule as follows

1. Stick a file in %userprofile%\Documents\Fiddler2\Captures\Responses folder

2. Highlight the request you want to set up a rule for

3. Got to the AutoResponder tab and check Enable automatic responses and unmagtched requests passthrough

4. Click Add rule

5. In the dropdown list control at the bottom, select the file that you dropped in the folder in step 1 above.

6. Hit the save button

7. Clear the Cache

clip_image001

Now next time you request that resource, the version you have saved on disk will be downloaded instead. You can check this by looking in the IE cache folder %userprofile

%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files

More detail about request and response breakpoints in fiddler here… (this is very useful should you wish to change the request going to the server in the first place as well)…

http://www.youtube.com/watch?v=8bo5kXMAcV0&list=PLvmaC-XMqeBbw72l2G7FG7CntDTErjbHc&index=2

P.S. For more powerful / permanent debugging solution you can just alter the fiddler customrules.js as follows

static function OnBeforeResponse(oSession: Session) {

        if (m_Hide304s && oSession.responseCode == 304) {

            oSession["ui-hide"] = "true";

        }

if (oSession.uriContains("Name=ViewerScript")) {

                                                oSession["x-replywithfile"]="Reserved.ReportViewerWebControl.axd";

                                }

    }

No comments:

Post a Comment