可輕松的修改 XHR 的請求和響應:XHook
XHook 可輕松的修改 XHR 的請求和響應。主要用于:
-
Cache requests in memory, localStorage, etc.
-
Insert authentication headers
-
S3 Request Signing, see S3 Hook
-
Simulate responses
-
Create fake transparent backends for testing purposes
-
Sending Error statistics to Google Analytics
-
Polyfil CORS, by offloading requests to an iframe then splicing the response back in, see XDomain
-
Devious practical jokes
-
Preflight GZip compression, see XZip (In progress)
示例代碼:
//modify 'responseText' of 'example2.txt' xhook.after(function(request, response) { if(request.url.match(/example\.txt$/)) response.text = response.text.replace(/[aeiou]/g,'z'); });
支持的瀏覽器:IE8+, Chrome, Firefox, Safari
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!