在線調試利器Fiddler AutoResponse


      有些時候在測試環境和線上環境的不同,導致在線系統的js難易跟蹤調試特別是一些動態js腳本。fiddler這個工具給我減少了很多調試上的煩惱,尤其是強大的AutoResponder.

它可以抓取在線頁面保存到本地進行調試,這大大減少了在線調試的困難。

下面以http://www.fiddler2.com/fiddler2為例簡單描述一下操作步驟:

1、打開fiddler2,在瀏覽器中輸入http://www.fiddler2.com/fiddler2。在fiddler2可以看到請求記錄。

2、選擇需要調試的頁面,右鍵-Save-Response-Response body

3、修改需要調試的代碼段。

4、點擊fiddler AutoResponder Tab頁面,勾選Enable automatic responses,把http://www.fiddler2.com/fiddler2/這面拖拽到AutoResponder 列表中。

    默認 Rule Editor為精匹配。在第二個文本框中選擇Find a file...,選擇本地保存后的文件。

5、保存規則后,重新請求http://www.fiddler2.com/fiddler2/,在看Fiddler websessions 列表新的請求Result 301,說明請求的是本地緩存的文件。

這樣就可以做我們想做的調試和修改了。

如果,你的請求是帶動態參數的化,可以使用正則表達式。

如:請求規則:Regex:(?insx)^http://.*gravatar.*$

                   Regex:(?insx)^http://.*WF_ID=WFDevFx_GCUSTOMIZE&ticket=.*$

*下面是詳細的過濾規則:

String Literals

Fiddler will match string literals (大小寫不敏感)

Rule

Matches

*

http://www.example.com/Path1/query=example

EXAMPLE

http://www.example.com/Path1/query=example

path1/

http://www.example.com/Path1/query=example

query

http://www.example.com/Path1/q=Query

Exact Match(精確匹配)

Fiddler supports an exact, 大小寫敏感 match syntax for expressions which begin with exact:

Rule

Matches

EXACT:http://www.example.com/path

http://www.example.com/path

EXACT:http://www.example.com/path

http://www.example.com/Path (No Match - mismatched case)

EXACT:http://www.example.com/path

http://www.example.com/path/q=Query (No Match - substring different)

Regular Expressions(正則表達式)

Fiddler supports regular expression syntax for expressions which begin with regex:

Rule

Matches

regex:.*

http://www.example.com/Path1/query=example

regex:.*\.jpg

http://www.example.com/Path1/query=foo.jpg&bar
http://www.example.com/Path1/query=example.jpg

regex:.*\.jpg$

http://www.example.com/Path1/query=foo.jpg&bar (No Match - improper ending)
http://www.example.com/Path1/query=example.jpg

regex:.*\.(jpg|gif|bmp)$

http://www.example.com/Path1/query=foo.bmp&bar (No Match  - improper ending)
http://www.example.com/Path1/query=example.gif
http://www.example.com/Path1/query=example.Gif  (No Match - mismatched case)
http://www.example.com/Path1/query=example.bmp

regex:(?insx).*\.(jpg|gif|bmp)$

http://www.example.com/Path1/query=foo.bmp&bar (No Match - improper ending)
http://www.example.com/Path1/query=example.gif
http://www.example.com/Path1/query=example.Gif 
http://www.example.com/Path1/query=example.bmp

 抓取帶參數的請求並重定向:

  請求:http://v.sdo.com/login/game_login.htm?isgamelogin=true&server=1&abb=csws&returnUrl=%2fcsws%2fplay.htm

      重定向:http://www.cnblogs.com/peak-weng/archive/2012/01/19/2325855.html?isgamelogin=true&server=1&abb=csws&returnUrl=%2fcsws%2fplay.htm

     在Rule Editor:表示為:

      regex:(?insx)^http://v.sdo.com/login/game_login.htm\?(?<args>.*)$

      *redir: http://www.cnblogs.com/peak-weng/archive/2012/01/19/2325855.html?${args}

  如圖:

     

     

 

參考文章:http://aiyooyoo.com/index.php/archives/250/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM