In Fiddler, a small test is performed on sripat and a small test is performed on fiddlersripat.
From the previous article, I used a simple function of Fiddler, HOSTS for forwarding and debugging of mobile apps, but some people may ask, HOSTS can only change the HOST, if there are the following scenarios, what should I do?
For example, the test server address is 192.168.0.69: 8080. The project name deployed is demo, that is, the complete access address is http: // 192.168.0.69: 8080/demo/
On the official server, the project may be directly deployed to the root directory: http://aip.demo.com
In this case, if you simply use HOSTS, it will not work, because the locally deployed project is not in the root directory, and the system prompts that the resource cannot be found. What should we do? I cannot deploy the project to the root directory for testing. This may affect other projects?
Well, in fact, there is no way to use HOSTS at this time. Another more powerful feature of fiddler should be used: script
On the fiddler page, click the FiddlerScript tag on the right to enter the FiddlerScript Editor (if not installed, Fiddler will prompt you to install it)
There is a Go to selection box under the tag, where you can quickly locate the corresponding method in the script. Here we need to change the request address, so the method we locate must be the OnBeforeRequest method:
Add the following to the OnBeforeRequest method:
if(oSession.uriContains("www.baidu.com")){ oSession.url = oSession.url.Replace("www.baidu.com","news.sina.com.cn/society/"); }
Here, we replaced Baidu with the social edition of Sina news. The effect is as follows:
We visited Baidu, but fiddler jumped to the Social edition page of Sina news, which solves the HOSTS deficiency in the previous article.
The functions of FiddlerScript are very powerful. Here I just try it out, which is a valuable reference. If you are interested, please take a closer look.