码迷,mamicode.com
首页 > 其他好文 > 详细

fidder 使用教程

时间:2016-06-21 19:02:01      阅读:752      评论:0      收藏:0      [点我收藏+]

标签:

 

fidder 使用教程

 

1. Fiddler 是什么?

Fiddler是用C#编写的一个免费的HTTP/HTTPS网络调试器。英语中Fiddler是小提琴的意思,Fiddler Web Debugger就像小提琴一样,可以让前端开发变得更加优雅。

Fiddler是以代理服务器的方式,监听系统的网络数据流动。运行Fiddler后,就会在本地打开8888端口,网络数据流通过Fiddler进行中转时,我们可以监视HTTP/HTTPS数据流的记录,并加以分析,甚至还可以修改发送和接收的数据。Fiddler还提供了清除IE缓存、请求构造器、文本转换工具等等一系列工具,对前端开发工作很有价值。

2. 下载和安装Fiddler

  1. 安装.net framework 2.0以上版本
  2. 官方网站免费下载Fiddler。

Firefox中用Fiddler,可以下载一个插件:Fiddler开关

3. Fiddler的界面和功能

技术分享

 

左侧是数据列表,以不同的图标区分数据类型和状态,以下是图标对应的含义:

技术分享 正在将请求数据发往服务器
技术分享 正在从服务器下载返回数据
技术分享 请求过程中暂停
技术分享 返回过程中暂停
技术分享 请求中使用了HTTP HEAD方法; 返回中应该没有body内容
技术分享 请求中使用了HTTP CONNECT方法,建立HTTPS连接通道
技术分享 返回的内容类型是HTML
技术分享 返回的内容类型是图片
技术分享 返回的内容类型是Javascript
技术分享 返回的内容类型是CSS
技术分享 返回的内容类型是XML
技术分享 普通的成功的返回
技术分享 返回内容为 HTTP/300,301,302,303 or 307 跳转
技术分享 返回内容为HTTP/304: 使用本地缓存
技术分享 返回内容为一个证书请求
技术分享 返回内容是服务器错误
技术分享 请求被客户端、Fiddler或服务器中断

 

 

 

 

 常用的命令行工具

   

命令行 - 允许你直接输入命令,详细官方文档介
http://docs.telerik.com/fiddler/KnowledgeBase/QuickExec

你也可以在命令行中输入“help” 

cls    清屏  (Ctrl+x 也可以清屏)

select  选择会话的命令

?.jpg  用来选择jpg后缀的图片的会话

bpu  截获request

?关键字

 

自定义规则 customrules.js 文件

  1 import System;
  2 import System.Windows.Forms;
  3 import Fiddler;
  4 
  5 // INTRODUCTION
  6 //
  7 // Well, hello there!
  8 //
  9 // Don‘t be scared! :-)
 10 //
 11 // This is the FiddlerScript Rules file, which creates some of the menu commands and
 12 // other features of Fiddler. You can edit this file to modify or add new commands.
 13 //
 14 // The original version of this file is named SampleRules.js and it is in the
 15 // \Program Files\Fiddler\ folder. When Fiddler first runs, it creates a copy named
 16 // CustomRules.js inside your \Documents\Fiddler2\Scripts folder. If you make a 
 17 // mistake in editing this file, simply delete the CustomRules.js file and restart
 18 // Fiddler. A fresh copy of the default rules will be created from the original
 19 // sample rules file.
 20 
 21 // The best way to edit this file is to install the FiddlerScript Editor, part of
 22 // the free SyntaxEditing addons. Get it here: http://fiddler2.com/r/?SYNTAXVIEWINSTALL
 23 
 24 // GLOBALIZATION NOTE: Save this file using UTF-8 Encoding.
 25 
 26 // JScript.NET Reference
 27 // http://fiddler2.com/r/?msdnjsnet
 28 //
 29 // FiddlerScript Reference
 30 // http://fiddler2.com/r/?fiddlerscriptcookbook
 31 
 32 class Handlers
 33 {
 34     // *****************
 35     //
 36     // This is the Handlers class. Pretty much everything you ever add to FiddlerScript
 37     // belongs right inside here, or inside one of the already-existing functions below.
 38     //
 39     // *****************
 40 
 41     // The following snippet demonstrates a custom-bound column for the Web Sessions list.
 42     // See http://fiddler2.com/r/?fiddlercolumns for more info
 43     /*
 44       public static BindUIColumn("Method", 60)
 45       function FillMethodColumn(oS: Session): String {
 46          return oS.RequestMethod;
 47       }
 48     */
 49 
 50     // The following snippet demonstrates how to create a custom tab that shows simple text
 51     /*
 52        public BindUITab("Flags")
 53        static function FlagsReport(arrSess: Session[]):String {
 54         var oSB: System.Text.StringBuilder = new System.Text.StringBuilder();
 55         for (var i:int = 0; i<arrSess.Length; i++)
 56         {
 57             oSB.AppendLine("SESSION FLAGS");
 58             oSB.AppendFormat("{0}: {1}\n", arrSess[i].id, arrSess[i].fullUrl);
 59             for(var sFlag in arrSess[i].oFlags)
 60             {
 61                 oSB.AppendFormat("\t{0}:\t\t{1}\n", sFlag.Key, sFlag.Value);
 62             }
 63         }
 64         return oSB.ToString();
 65     }
 66     */
 67 
 68     // You can create a custom menu like so:
 69     /*
 70     QuickLinkMenu("&Links") 
 71     QuickLinkItem("IE GeoLoc TestDrive", "http://ie.microsoft.com/testdrive/HTML5/Geolocation/Default.html")
 72     QuickLinkItem("FiddlerCore", "http://fiddler2.com/fiddlercore")
 73     public static function DoLinksMenu(sText: String, sAction: String)
 74     {
 75         Utilities.LaunchHyperlink(sAction);
 76     }
 77     */
 78 
 79     public static RulesOption("Hide 304s")
 80     BindPref("fiddlerscript.rules.Hide304s")
 81     var m_Hide304s: boolean = false;
 82 
 83     // Cause Fiddler to override the Accept-Language header with one of the defined values
 84     public static RulesOption("Request &Japanese Content")
 85     var m_Japanese: boolean = false;
 86 
 87     // Automatic Authentication
 88     public static RulesOption("&Automatically Authenticate")
 89     BindPref("fiddlerscript.rules.AutoAuth")
 90     var m_AutoAuth: boolean = false;
 91 
 92     // Cause Fiddler to override the User-Agent header with one of the defined values
 93     // The page http://browserscope2.org/browse?category=selectors&ua=Mobile%20Safari is a good place to find updated versions of these
 94     RulesString("&User-Agents", true) 
 95     BindPref("fiddlerscript.ephemeral.UserAgentString")
 96     //RulesStringValue(0,"Netscape &3", "Mozilla/3.0 (Win95; I)")
 97    // RulesStringValue(1,"WinPhone8.1", "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 520) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537")
 98    // RulesStringValue(2,"&Safari5 (Win7)", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1")
 99     RulesStringValue(3,"Safari9 (Mac)", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.56 (KHTML, like Gecko) Version/9.0 Safari/601.1.56")
100     RulesStringValue(4,"iPad", "Mozilla/5.0 (iPad; CPU OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F5027d Safari/600.1.4")
101     RulesStringValue(5,"iPhone6", "Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4")
102    // RulesStringValue(6,"IE &6 (XPSP2)", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
103    // RulesStringValue(7,"IE &7 (Vista)", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1)")
104    // RulesStringValue(8,"IE 8 (Win2k3 x64)", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64; Trident/4.0)")
105    //RulesStringValue(9,"IE &8 (Win7)", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)")
106     //RulesStringValue(10,"IE 9 (Win7)", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)")
107    // RulesStringValue(11,"IE 10 (Win8)", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)")
108     //RulesStringValue(12,"IE 11 (Surface2)", "Mozilla/5.0 (Windows NT 6.3; ARM; Trident/7.0; Touch; rv:11.0) like Gecko")
109     //RulesStringValue(13,"IE 11 (Win8.1)", "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko")
110   //  RulesStringValue(14,"Edge (Win10)", "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.11082")
111     RulesStringValue(15,"&Opera", "Opera/9.80 (Windows NT 6.2; WOW64) Presto/2.12.388 Version/12.17")
112     RulesStringValue(16,"&Firefox 3.6", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.7) Gecko/20100625 Firefox/3.6.7")
113     RulesStringValue(17,"&Firefox 43", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0")
114     RulesStringValue(18,"&Firefox Phone", "Mozilla/5.0 (Mobile; rv:18.0) Gecko/18.0 Firefox/18.0")
115     RulesStringValue(19,"&Firefox (Mac)", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0")
116     //RulesStringValue(20,"Chrome (Win)", "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.48 Safari/537.36")
117    // RulesStringValue(21,"Chrome (Android)", "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.78 Mobile Safari/537.36")
118    // RulesStringValue(22,"ChromeBook", "Mozilla/5.0 (X11; CrOS x86_64 6680.52.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.74 Safari/537.36")
119    // RulesStringValue(23,"GoogleBot Crawler", "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
120    // RulesStringValue(24,"Kindle Fire (Silk)", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.0.22.79_10013310) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true")
121     RulesStringValue(25,"&Custom...", "%CUSTOM%")
122     public static var sUA: String = null;
123 
124     // Cause Fiddler to delay HTTP traffic to simulate typical 56k modem conditions
125     public static RulesOption("Simulate &Modem Speeds", "Per&formance")
126     var m_SimulateModem: boolean = false;
127 
128     // Removes HTTP-caching related headers and specifies "no-cache" on requests and responses
129     public static RulesOption("&Disable Caching", "Per&formance")
130     var m_DisableCaching: boolean = false;
131 
132     public static RulesOption("Cache Always &Fresh", "Per&formance")
133     var m_AlwaysFresh: boolean = false;
134         
135     // Force a manual reload of the script file.  Resets all
136     // RulesOption variables to their defaults.
137     public static ToolsAction("Reset Script")
138     function DoManualReload() { 
139         FiddlerObject.ReloadScript();
140     }
141 
142     public static ContextAction("Decode Selected Sessions")
143     function DoRemoveEncoding(oSessions: Session[]) {
144         for (var x:int = 0; x < oSessions.Length; x++){
145             oSessions[x].utilDecodeRequest();
146             oSessions[x].utilDecodeResponse();
147         }
148         UI.actUpdateInspector(true,true);
149     }
150 
151     static function OnBeforeRequest(oSession: Session) {
152         // Sample Rule: Color ASPX requests in RED
153         // if (oSession.uriContains(".aspx")) {    oSession["ui-color"] = "red";    }
154 
155         // Sample Rule: Flag POSTs to fiddler2.com in italics
156         // if (oSession.HostnameIs("www.fiddler2.com") && oSession.HTTPMethodIs("POST")) {    oSession["ui-italic"] = "yup";    }
157 
158         // Sample Rule: Break requests for URLs containing "/sandbox/"
159         // if (oSession.uriContains("/sandbox/")) {
160         //     oSession.oFlags["x-breakrequest"] = "yup";    // Existence of the x-breakrequest flag creates a breakpoint; the "yup" value is unimportant.
161         // }
162         //===============================李度编写start=========================
163         if (oSession.HostnameIs("www.fiddler2.com") && oSession.HTTPMethodIs("POST"))
164             {    oSession["ui-hide"] = true;    }
165         if(oSession.HostnameIs("sofire.baidu.com")||oSession.HostnameIs("clients1.google.com")||oSession.HostnameIs("sp1.baidu.com:443")||oSession.HostnameIs("oc.umeng.com")||oSession.HostnameIs("sp1.baidu.com:443"))
166         {
167                oSession["ui-hide"] = "true"; 
168             
169          }
170       if (oSession.uriContains("baidu")||oSession.uriContains("bdstatic")||oSession.uriContains("opera")
171             ||oSession.uriContains("adsafe")||oSession.uriContains("microsoft")||oSession.uriContains("qq")
172             ||oSession.uriContains("oupeng")||oSession.uriContains("umeng")||oSession.uriContains("ad")
173             ||oSession.uriContains("googleapis")||oSession.uriContains("xiaomi")||oSession.uriContains("apple")
174         ) 
175             {    
176             oSession["ui-color"] = "green";
177             oSession["ui-hide"] = "true"; 
178             }
179         //===============================李度编写over=========================
180 
181         if ((null != gs_ReplaceToken) && (oSession.url.indexOf(gs_ReplaceToken)>-1)) {   // Case sensitive
182             oSession.url = oSession.url.Replace(gs_ReplaceToken, gs_ReplaceTokenWith); 
183         }
184         if ((null != gs_OverridenHost) && (oSession.host.toLowerCase() == gs_OverridenHost)) {
185             oSession["x-overridehost"] = gs_OverrideHostWith; 
186         }
187 
188         if ((null!=bpRequestURI) && oSession.uriContains(bpRequestURI)) {
189             oSession["x-breakrequest"]="uri";
190         }
191 
192         if ((null!=bpMethod) && (oSession.HTTPMethodIs(bpMethod))) {
193             oSession["x-breakrequest"]="method";
194         }
195 
196         if ((null!=uiBoldURI) && oSession.uriContains(uiBoldURI)) {
197             oSession["ui-bold"]="QuickExec";
198         }
199 
200         if (m_SimulateModem) {
201             // Delay sends by 300ms per KB uploaded.
202             oSession["request-trickle-delay"] = "300"; 
203             // Delay receives by 150ms per KB downloaded.
204             oSession["response-trickle-delay"] = "150"; 
205         }
206 
207         if (m_DisableCaching) {
208             oSession.oRequest.headers.Remove("If-None-Match");
209             oSession.oRequest.headers.Remove("If-Modified-Since");
210             oSession.oRequest["Pragma"] = "no-cache";
211         }
212 
213         // User-Agent Overrides
214         if (null != sUA) {
215             oSession.oRequest["User-Agent"] = sUA; 
216         }
217 
218         if (m_Japanese) {
219             oSession.oRequest["Accept-Language"] = "ja";
220         }
221 
222         if (m_AutoAuth) {
223             // Automatically respond to any authentication challenges using the 
224             // current Fiddler user‘s credentials. You can change (default)
225             // to a domain\\username:password string if preferred.
226             //
227             // WARNING: This setting poses a security risk if remote 
228             // connections are permitted!
229             oSession["X-AutoAuth"] = "(default)";
230         }
231 
232         if (m_AlwaysFresh && (oSession.oRequest.headers.Exists("If-Modified-Since") || oSession.oRequest.headers.Exists("If-None-Match")))
233         {
234             oSession.utilCreateResponseAndBypassServer();
235             oSession.responseCode = 304;
236             oSession["ui-backcolor"] = "Lavender";
237         }
238     }
239 
240     // This function is called immediately after a set of request headers has
241     // been read from the client. This is typically too early to do much useful
242     // work, since the body hasn‘t yet been read, but sometimes it may be useful.
243     //
244     // For instance, see 
245     // http://blogs.msdn.com/b/fiddler/archive/2011/11/05/http-expect-continue-delays-transmitting-post-bodies-by-up-to-350-milliseconds.aspx
246     // for one useful thing you can do with this handler.
247     //
248     // Note: oSession.requestBodyBytes is not available within this function!
249 /*
250     static function OnPeekAtRequestHeaders(oSession: Session) {
251         var sProc = ("" + oSession["x-ProcessInfo"]).ToLower();
252         if (!sProc.StartsWith("mylowercaseappname")) oSession["ui-hide"] = "NotMyApp";
253     }
254 */
255 
256     //
257     // If a given session has response streaming enabled, then the OnBeforeResponse function 
258     // is actually called AFTER the response was returned to the client.
259     //
260     // In contrast, this OnPeekAtResponseHeaders function is called before the response headers are 
261     // sent to the client (and before the body is read from the server).  Hence this is an opportune time 
262     // to disable streaming (oSession.bBufferResponse = true) if there is something in the response headers 
263     // which suggests that tampering with the response body is necessary.
264     // 
265     // Note: oSession.responseBodyBytes is not available within this function!
266     //
267     static function OnPeekAtResponseHeaders(oSession: Session) {
268         //FiddlerApplication.Log.LogFormat("Session {0}: Response header peek shows status is {1}", oSession.id, oSession.responseCode);
269         if (m_DisableCaching) {
270             oSession.oResponse.headers.Remove("Expires");
271             oSession.oResponse["Cache-Control"] = "no-cache";
272         }
273 
274         if ((bpStatus>0) && (oSession.responseCode == bpStatus)) {
275             oSession["x-breakresponse"]="status";
276             oSession.bBufferResponse = true;
277         }
278         
279         if ((null!=bpResponseURI) && oSession.uriContains(bpResponseURI)) {
280             oSession["x-breakresponse"]="uri";
281             oSession.bBufferResponse = true;
282         }
283 
284     }
285 
286     static function OnBeforeResponse(oSession: Session) {
287         if (m_Hide304s && oSession.responseCode == 304) {
288             oSession["ui-hide"] = "true";
289         }
290     }
291 
292 /*
293     // This function executes just before Fiddler returns an error that it has 
294     // itself generated (e.g. "DNS Lookup failure") to the client application.
295     // These responses will not run through the OnBeforeResponse function above.
296     static function OnReturningError(oSession: Session) {
297     }
298 */
299 /*
300     // This function executes after Fiddler finishes processing a Session, regardless
301     // of whether it succeeded or failed. Note that this typically runs AFTER the last
302     // update of the Web Sessions UI listitem, so you must manually refresh the Session‘s
303     // UI if you intend to change it.
304     static function OnDone(oSession: Session) {
305     }
306 */
307 
308     /*
309     static function OnBoot() {
310         MessageBox.Show("Fiddler has finished booting");
311         System.Diagnostics.Process.Start("iexplore.exe");
312 
313         UI.ActivateRequestInspector("HEADERS");
314         UI.ActivateResponseInspector("HEADERS");
315     }
316     */
317 
318     /*
319     static function OnBeforeShutdown(): Boolean {
320         // Return false to cancel shutdown.
321         return ((0 == FiddlerApplication.UI.lvSessions.TotalItemCount()) ||
322                 (DialogResult.Yes == MessageBox.Show("Allow Fiddler to exit?", "Go Bye-bye?",
323                  MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)));
324     }
325     */
326 
327     /*
328     static function OnShutdown() {
329             MessageBox.Show("Fiddler has shutdown");
330     }
331     */
332 
333     /*
334     static function OnAttach() {
335         MessageBox.Show("Fiddler is now the system proxy");
336     }
337     */
338 
339     /*
340     static function OnDetach() {
341         MessageBox.Show("Fiddler is no longer the system proxy");
342     }
343     */
344 
345     // The Main() function runs everytime your FiddlerScript compiles
346     static function Main() {
347         var today: Date = new Date();
348         FiddlerObject.StatusText = " CustomRules.js was loaded at: " + today;
349 
350         // Uncomment to add a "Server" column containing the response "Server" header, if present
351         // UI.lvSessions.AddBoundColumn("Server", 50, "@response.server");
352 
353         // Uncomment to add a global hotkey (Win+G) that invokes the ExecAction method below...
354         // UI.RegisterCustomHotkey(HotkeyModifiers.Windows, Keys.G, "screenshot"); 
355     }
356 
357     // These static variables are used for simple breakpointing & other QuickExec rules 
358     BindPref("fiddlerscript.ephemeral.bpRequestURI")
359     public static var bpRequestURI:String = null;
360 
361     BindPref("fiddlerscript.ephemeral.bpResponseURI")
362     public static var bpResponseURI:String = null;
363 
364     BindPref("fiddlerscript.ephemeral.bpMethod")
365     public static var bpMethod: String = null;
366 
367     static var bpStatus:int = -1;
368     static var uiBoldURI: String = null;
369     static var gs_ReplaceToken: String = null;
370     static var gs_ReplaceTokenWith: String = null;
371     static var gs_OverridenHost: String = null;
372     static var gs_OverrideHostWith: String = null;
373 
374     // The OnExecAction function is called by either the QuickExec box in the Fiddler window,
375     // or by the ExecAction.exe command line utility.
376     static function OnExecAction(sParams: String[]): Boolean {
377 
378         FiddlerObject.StatusText = "ExecAction: " + sParams[0];
379 
380         var sAction = sParams[0].toLowerCase();
381         switch (sAction) {
382         case "bold":
383             if (sParams.Length<2) {uiBoldURI=null; FiddlerObject.StatusText="Bolding cleared"; return false;}
384             uiBoldURI = sParams[1]; FiddlerObject.StatusText="Bolding requests for " + uiBoldURI;
385             return true;
386         case "bp":
387             FiddlerObject.alert("bpu = breakpoint request for uri\nbpm = breakpoint request method\nbps=breakpoint response status\nbpafter = breakpoint response for URI");
388             return true;
389         case "bps":
390             if (sParams.Length<2) {bpStatus=-1; FiddlerObject.StatusText="Response Status breakpoint cleared"; return false;}
391             bpStatus = parseInt(sParams[1]); FiddlerObject.StatusText="Response status breakpoint for " + sParams[1];
392             return true;
393         case "bpv":
394         case "bpm":
395             if (sParams.Length<2) {bpMethod=null; FiddlerObject.StatusText="Request Method breakpoint cleared"; return false;}
396             bpMethod = sParams[1].toUpperCase(); FiddlerObject.StatusText="Request Method breakpoint for " + bpMethod;
397             return true;
398         case "bpu":
399             if (sParams.Length<2) {bpRequestURI=null; FiddlerObject.StatusText="RequestURI breakpoint cleared"; return false;}
400             bpRequestURI = sParams[1]; 
401             FiddlerObject.StatusText="RequestURI breakpoint for "+sParams[1];
402             return true;
403         case "bpa":
404         case "bpafter":
405             if (sParams.Length<2) {bpResponseURI=null; FiddlerObject.StatusText="ResponseURI breakpoint cleared"; return false;}
406             bpResponseURI = sParams[1]; 
407             FiddlerObject.StatusText="ResponseURI breakpoint for "+sParams[1];
408             return true;
409         case "overridehost":
410             if (sParams.Length<3) {gs_OverridenHost=null; FiddlerObject.StatusText="Host Override cleared"; return false;}
411             gs_OverridenHost = sParams[1].toLowerCase();
412             gs_OverrideHostWith = sParams[2];
413             FiddlerObject.StatusText="Connecting to [" + gs_OverrideHostWith + "] for requests to [" + gs_OverridenHost + "]";
414             return true;
415         case "urlreplace":
416             if (sParams.Length<3) {gs_ReplaceToken=null; FiddlerObject.StatusText="URL Replacement cleared"; return false;}
417             gs_ReplaceToken = sParams[1];
418             gs_ReplaceTokenWith = sParams[2].Replace(" ", "%20");  // Simple helper
419             FiddlerObject.StatusText="Replacing [" + gs_ReplaceToken + "] in URIs with [" + gs_ReplaceTokenWith + "]";
420             return true;
421         case "allbut":
422         case "keeponly":
423             if (sParams.Length<2) { FiddlerObject.StatusText="Please specify Content-Type to retain during wipe."; return false;}
424             UI.actSelectSessionsWithResponseHeaderValue("Content-Type", sParams[1]);
425             UI.actRemoveUnselectedSessions();
426             UI.lvSessions.SelectedItems.Clear();
427             FiddlerObject.StatusText="Removed all but Content-Type: " + sParams[1];
428             return true;
429         case "stop":
430             UI.actDetachProxy();
431             return true;
432         case "start":
433             UI.actAttachProxy();
434             return true;
435         case "cls":
436         case "clear":
437             UI.actRemoveAllSessions();
438             return true;
439         case "g":
440         case "go":
441             UI.actResumeAllSessions();
442             return true;
443         case "goto":
444             if (sParams.Length != 2) return false;
445             Utilities.LaunchHyperlink("http://www.google.com/search?hl=en&btnI=I%27m+Feeling+Lucky&q=" + Utilities.UrlEncode(sParams[1]));
446             return true;
447         case "help":
448             Utilities.LaunchHyperlink("http://fiddler2.com/r/?quickexec");
449             return true;
450         case "hide":
451             UI.actMinimizeToTray();
452             return true;
453         case "log":
454             FiddlerApplication.Log.LogString((sParams.Length<2) ? "User couldn‘t think of anything to say..." : sParams[1]);
455             return true;
456         case "nuke":
457             UI.actClearWinINETCache();
458             UI.actClearWinINETCookies(); 
459             return true;
460         case "screenshot":
461             UI.actCaptureScreenshot(false);
462             return true;
463         case "show":
464             UI.actRestoreWindow();
465             return true;
466         case "tail":
467             if (sParams.Length<2) { FiddlerObject.StatusText="Please specify # of sessions to trim the session list to."; return false;}
468             UI.TrimSessionList(int.Parse(sParams[1]));
469             return true;
470         case "quit":
471             UI.actExit();
472             return true;
473         case "dump":
474             UI.actSelectAll();
475             UI.actSaveSessionsToZip(CONFIG.GetPath("Captures") + "dump.saz");
476             UI.actRemoveAllSessions();
477             FiddlerObject.StatusText = "Dumped all sessions to " + CONFIG.GetPath("Captures") + "dump.saz";
478             return true;
479 
480         default:
481             if (sAction.StartsWith("http") || sAction.StartsWith("www.")) {
482                 System.Diagnostics.Process.Start(sParams[0]);
483                 return true;
484             }
485             else
486             {
487                 FiddlerObject.StatusText = "Requested ExecAction: ‘" + sAction + "‘ not found. Type HELP to learn more.";
488                 return false;
489             }
490         }
491     }
492 }

 

fidder 使用教程

标签:

原文地址:http://www.cnblogs.com/laopo/p/5604554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!