如何在Fiddler中显示HTTP请求的大小?

M4N*_*M4N 12 http fiddler web-traffic

我想在fiddler的会话列表中显示每个请求的大小.我到目前为止尝试的是在CustomRules.js文件中添加自定义列:

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

但是当fiddler尝试加载脚本时,这会导致错误.

如果我用注释改变这一行:

    return typeof(oS.requestBodyBytes.Length);
Run Code Online (Sandbox Code Playgroud)

然后fiddler在RequestSize列中显示'number'.因此,我想我离我想要实现的目标并不是很远.我只是想不通如何显示requestBodyBytes字段的大小.

什么提示我做错了什么或缺少什么?

Eri*_*Law 10

更新在现代版本的Fiddler中,您只需右键单击列标题,选择"自定义列"并添加Miscellaneous> Request Size列.


根据您的需要,这可能不是您想要做的,因为它只显示请求正文的长度,并且不包括标题的大小.

这是一个改进版本:

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();
}
Run Code Online (Sandbox Code Playgroud)


M4N*_*M4N 5

好的,我知道我并不遥远.这是我的问题的答案.

此脚本放入CustomRules.js时,将在fiddler中打印HTTP请求的长度/大小:

public  static  BindUIColumn("Req-Length")
function  CalcMethodCol(oS:  Session){
    if (null != oS.oRequest)
            return oS.requestBodyBytes.LongLength.ToString();
        else
            return String.Empty;
}
Run Code Online (Sandbox Code Playgroud)