Ebay - Advertisement

Monday, May 24, 2010

Fiddler GZIP Issue

Recenly, I found that the GZIP zip/unzip feature in fiddler does not work properly. There are applications which are based on HTTP protocol and also zip HTTP Requests and Responses with GZIP format. So I decided to write some script using Fiddler Script Editor for converting and extracting Requests that are in GZIP format. Here is the code, copy this to the CustomRules.js file (Rules---->Customize Rules)
public static ContextAction("GZIP Request")
       function GZIPRequest(oSessions:Session[]){
              Utilities.WriteArrayToFile("c:\\fidreq.txt",Utilities.GzipCompress(oSessions[oSessions.Length-1].requestBodyBytes));
              oSessions[oSessions.Length-1].LoadRequestBodyFromFile("c:\\fidreq.txt");
              }  
       public static ContextAction("UNGZIP Request")
       function UNGZIPRequest(oSessions:Session[]){
              var oBody = System.Text.Encoding.UTF8.GetString(Utilities.GzipExpand(oSessions[oSessions.Length-1].requestBodyBytes));
              oSessions[oSessions.Length-1].utilSetRequestBody(oBody);
       }
public static ContextAction("GZIP Response")
       function GZIPResponse(oSessions:Session[]){
       
              Utilities.WriteArrayToFile("c:\\fidres.txt",Utilities.GzipCompress(oSessions[oSessions.Length-1].responseBodyBytes));
              oSessions[oSessions.Length-1].LoadResponseFromFile("c:\\fidres.txt");
       }
public static ContextAction("UNGZIP Response")
       function UNGZIPResponse(oSessions:Session[]){  
              var oBody = System.Text.Encoding.UTF8.GetString(Utilities.GzipExpand(oSessions[oSessions.Length-1].responseBodyBytes));
              oSessions[oSessions.Length-1].utilSetResponseBody(oBody);
              oSessions[oSessions.Length-1].RefreshUI();
       }
After copying this code, and saving it in the CustomRules.js files, select one of the HTTP Requests which are in GZIP format, right click and... here it is...you will have 4 options: GZIP Request, GZIP Response, UNGZIP Response, UNGZIP Request Have fun ;-)

No comments:

Post a Comment