zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Fiddler 在列表中显示图片尺寸

2023-03-07 09:46:27 时间

官方文档

https://docs.telerik.com/fiddler/knowledgebase/fiddlerscript/customizesessionslist

在列中添加图像尺寸信息(全局范围)

注意:必须在 Tools > Fiddler Options > Extensions > References 内添加 System.drawing.dll.

class Handlers
{

    // 在列中添加图像尺寸信息
    public static BindUIColumn("ImageSize", 60)
    function FillImageSizeColumn(oS: Session){
        if ((oS.oResponse != null) && (oS.oResponse.headers != null))
        {
            try{
                if (!oS.oResponse.headers.ExistsAndContains("Content-Type", "image/")) return "NotAnImage";

                var oMS: System.IO.MemoryStream = new System.IO.MemoryStream(oS.responseBodyBytes);
                var i:System.Drawing.Bitmap = new System.Drawing.Bitmap(oMS);
                return (i.Width + " * " + i.Height);
            }
            catch(e) { return "GetSizeError"; }
        }
        return String.Empty;
    }

}

效果图