Kent Sanner
Kent Sanner

Reputation: 15

FiddlerScript saving blank file with oSession.SaveResponse

Simply trying to save a request and response to separate .txt files. Request saves fine but the response is saving blank files, is there additional code needed for responses that's not used for requests? I've compared this code to other posts on SO and other sites but can't identify anything I'm missing.

Both the SaveResponse and SaveResponseBody commands run but save blank files

if(oSession.url.StartsWith("www.google.com")){
        // Save Request
        oSession.utilDecodeRequest();
        oSession.SaveRequest("C:\\temp\\" + oSession.SuggestedFilename + "-request.txt",true);
        // Save Response  
        oSession.utilDecodeResponse();
        oSession.SaveResponse("C:\\temp\\" + oSession.SuggestedFilename + "-response.txt",true);
        oSession.SaveResponseBody("C:\\temp\\" + oSession.SuggestedFilename);
}

Upvotes: 1

Views: 379

Answers (1)

Borislav Ivanov
Borislav Ivanov

Reputation: 5360

You are probably inspecting the session too early, when the response is still not received. Try moving the logic to OnDone, which is executed after the response is received:

    static function OnDone(oSession: Session)
    {
        if(oSession.url.StartsWith("www.google.com")){
            // Save Request
            oSession.utilDecodeRequest();
            oSession.SaveRequest("c:\\temp\\" + oSession.SuggestedFilename + "-request.txt",true);
            // Save Response  
            oSession.utilDecodeResponse();
            oSession.SaveResponse("c:\\temp\\" + oSession.SuggestedFilename + "-response.txt",true);
            oSession.SaveResponseBody("c:\\temp\\" + oSession.SuggestedFilename);
        }
    }

Upvotes: 1

Related Questions