1. 程式人生 > 其它 >fiddler autoresponder 動態修改響應內容

fiddler autoresponder 動態修改響應內容

fiddlerautoresponder 功能可以攔截請求並指定響應 ,但是這個響應目前看來都是固定的一個檔案或者地址,無法根據被攔截請求中的引數來定製化響應內容(不一定對,歡迎指正 )。

搜尋了很多資料,發現可以通過 Rules 選單中的 Customize Rules... 來完成上述任務,

點選該選單後,會開啟一個js檔案,裡面是一個高階功能,需要寫程式碼擴充套件 ,
可以點選選單欄 go**** , 然後 to OnBeforeResponse ,會定位到 OnBeforeResponse 函式,我們的程式碼將寫在該程式碼塊中 。


	static function OnBeforeResponse(oSession: Session) {

		if (oSession.HostnameIs("xxxxx.xxxxx.cn")){  //只處理目標站點
		    var abc = oSession.url;  //當前會話的url   xxxx.xxxxx.cn/fege/age.html?cid=655 
            var cid = abc.substring(abc.indexOf('=')+1,abc.length);   //擷取url中引數 (應該有介面可以方便獲取,這個比較笨)  
			oSession.utilDecodeResponse();
			oSession.utilReplaceInResponse('622',cid );
		}
		
		
	}

以上是寫的一段demo ,他可以將指定網站上所有響應裡面的 622 換成 querystring 中的 655

https://docs.telerik.com/fiddler/knowledge-base/fiddlerscript/modifyrequestorresponse

https://docs.telerik.com/fiddler/knowledge-base/autoresponder

轉載請遵循此協議:署名 - 非商業用途 - 保持一致

並保留此連結:http://fejerry.cnblogs.com/