fiddlerscript-Common Summary

Source: Internet
Author: User

No use of fiddler people should have no feelings for fiddlerscript, I really feel fiddlerscript to test have certain help ha.

In the Web front-end development process, Fiddler is the most common debugging tool, that for testing, it is also a great tool for testing. In most cases, our basic use can be met through the Fiddler menu, but it involves more complex scenarios that cannot be met through the Fiddler basic menu. Then you can use Fiddlerscript,

1 through breakpoints can modify the HTTP request and the corresponding data, but can not change the HTTP header, url,http the corresponding code and so on, so this time fiddlerscript can climb in handy.

2 because set breakpoints to change the HTTP request data, manually find the parameters, input, click the Restart button, this series of actions will take a certain amount of time, and sometimes the previous paragraph to determine the response time is relatively short, there is no time to modify, response times timeout, then the change is invalid, So this time fiddlerscript implementation of automatic modification will climb to the useful.

The following is a description of my usual fiddlerscript, onbeforerequest part

You can change the HTTP header file in either of two ways
if (Osession.uricontains ("172.16.0.62")) {
osession.orequest.headers["lat"]= "22.547";
Osession.orequest["lon"] = "114.125";
}
Remove a header file
if (Osession.uricontains ("objectid=1")) {
osession.orequest.headers.remove["lat"];
}
Add header File
if (Osession.uricontains ("172.16.0.61")) {
OSESSION.OREQUEST.HEADERS.ADD ("Lat", "22.548")
}
Host is to write the complete
if (Osession.host = = "hstoa.wisdom-gps.com:8888") {
}

if (Osession.uricontains ("172.16.0.61")) {
osession["Ui-color"] = "winered";
}

Modify the GET Request URL
if (Osession.uricontains ("C_account/logon")) {
var Geturl = Osession.url
Geturl=geturl. Replace ("111111", "222222");
Osession.url = Geturl;
}

Modify the Boby of a POST request
var strbody=osession.getrequestbodyasstring ();
To modify a string with a regular expression or replace method
Strbody=strbody.replace ("1111", "2222");
Check the modified body with a dialog box
Fiddlerobject.alert (strbody);
Re-write the modified body back to request
Osession.utilsetrequestbody (strbody);

Replace the HTTP protocol in the request URI with the HTTPS protocol
Osession.fullurl = "https" + oSession.fullUrl.Substring (oSession.fullUrl.IndexOf (': '));

Common Onbeforeresponse Parts:

Add response header
if (Osession.uricontains ("C_account/logon")) {
OSESSION.ORESPONSE.HEADERS.ADD ("Test1", "11111")
}
Modify the response header
if (Osession.uricontains ("C_account/logon")) {
osession.oresponse.headers["Date"] = "Wed, Oct 03:11:15 GMT";
}
Remove the response header
if (Osession.uricontains ("C_account/logon")) {
osession.oresponse.headers.remove["Date"];
}
Modify the HTTP status code
if (Osession.uricontains ("C_account/logon")) {
Osession.responsecode = "404"
}
Modify the response Boby, such as modifying the result value 1 to 2
if (Osession.uricontains ("C_account/logon")) {
var bobystr = osession.getresponsebodyasstring ();
Bobystr = Bobystr. Replace ("\" result\ ": 1", "\" result\ ": 2");
Osession.utilsetresponsebody (BOBYSTR);
}
Response Status Identification color
if (Osession.uricontains ("C_account/logon")) {
var reponseboby = osession.getresponsebodyasstring ()
if (Reponseboby. Contains ("\" result\ ": 0")) {
osession["Ui-color"] = "blue";
}
}




This article from the "Summary of the Journey" blog, declined reprint!

fiddlerscript-Common Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.