How to display the size of a HTTP request in Fiddler?

10,632

Solution 1

Update In modern versions of Fiddler, you can simply right-click the column headers, choose "Customize Columns" and add the Miscellaneous > Request Size column.


Depending on your needs, that might not really be what you want to do, because it only shows the length of the request body, and doesn't include the size of the headers.

Here's an improved version:

public  static  BindUIColumn("Req-Size")
function  CalcReqSize(oS:  Session){        
  if (null == oS.oRequest) return String.Empty;
  var cBytesOut: int = 0;

  if (null != oS.requestBodyBytes) cBytesOut += oS.requestBodyBytes.LongLength; 
  if ((null != oS.oRequest) && (null != oS.oRequest.headers)) cBytesOut += 
  oS.oRequest.headers.ByteCount() ; 
  return cBytesOut.ToString();
}

Solution 2

OK, I knew I wasn't far off. Here's the answer to my question.

This script, when put into CustomRules.js, will print the length/size of HTTP request in fiddler:

public  static  BindUIColumn("Req-Length")
function  CalcMethodCol(oS:  Session){
    if (null != oS.oRequest)
            return oS.requestBodyBytes.LongLength.ToString();
        else
            return String.Empty;
}
Share:
10,632
M4N
Author by

M4N

Software developer, mainly using ASP.NET/C#. #SOreadytohelp

Updated on June 07, 2022

Comments

  • M4N
    M4N almost 2 years

    I'd like to display the size of each request in the session list of fiddler. What I tried so far, was to add a custom column in the CustomRules.js file:

    public static BindUIColumn("RequestSize")
    function CalcMethodCol(oS: Session)
    {
      if (null != oS.requestBodyBytes)
        return oS.requestBodyBytes.Length; //this is the relevant line
      else
        return "?";
    }
    

    But this results in an error when fiddler tries to load the script.

    If I change the line with the comment to this:

        return typeof(oS.requestBodyBytes.Length);
    

    then fiddler displays 'number' in the RequestSize column. Because of that I guess that I'm not very far away from what I'm trying to achieve. I just can't figure out how to display the size of the requestBodyBytes field.

    Any hints what I'm doing wrong or what is missing?

  • Andrea Balducci
    Andrea Balducci about 12 years
    tested in fiddler 2.3.9.1beta -> requestBodyBytes.LongLength becomes requestBodyBytes.Length
  • EricLaw
    EricLaw almost 11 years
    LongLength and Length return the same thing.
  • Kevin Doyon
    Kevin Doyon over 8 years
    I had to use var cBytesOut:int = 0 otherwise Fiddler was complaining that the function was returning System.Object and not a string.