Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fiddler script to automatically save response body

I need help writing a script for fiddler. What I need is to automatically save a certain response body every time it comes up in the session window.

I have tried to follow the instructions in this post Fiddler Script - SaveResponseBody() but I just get an error when I try and save CustomRules.js. (I could be inserting in wrong or in the wrong place)

I am new to fiddler and scripts so any help here would be greatly appreciated.

I have tried adding this:

static function OnBeforeResponse(oSession: Session) {
   if(oSession.url.EndsWith(".png")) {
      oSession.SaveResponseBody(); //Actual content of OnBeforeResponse function.
   }
}

and then adding this:

if ((oSession.responseCode == 200) &&
    oSession.oResponse.headers.ExistsAndContains("Content-Type", "image/png")) {
   SaveResponseBody("C:\\temp\\" + oSession.SuggestedFilename);
}

to the CustomRules.js script.

like image 416
Jason Avatar asked Aug 20 '14 22:08

Jason


1 Answers

SaveResponseBody is a method on the oSession object.

oSession.SaveResponseBody("C:\\temp\\" + oSession.SuggestedFilename);
like image 176
myartsev Avatar answered Oct 06 '22 00:10

myartsev