charles rewrite Tools / rewrite Srttings

Reference article: charles rewrite tool rewrite Srttings

Rewrite Tools / rewrite Srttings and rewrite rule

Function: when the modification request and response by charles

Rewrite tool

Rewrite tool allows you to have time to respond to the request, modify the request and response rule.

rule (rule): Add or change the title or replace some text in the body of the response, edit the data.

Set rewriting rewriting can be set individually activated and deactivated. Each set contains a list of positions and rules. In response to these requests, and position selecting rule will run.

Rewrite rule: each individual rule described rewriting operation. heading rule may affect the request URL, the body or part; it can operate according to the request or the response;

Then it can define a search and replace, or replace just the style rewrite, rewrite rule editor dialog box, provide more documentation about the rewrite rule, you can look.

local match each local matching may contain protocol, host, port, and path pattern to match a specific URL. local can use wildcards.


Debugging
When the rewrite operation does not work, rewriting tool may be difficult to debug. If you are having trouble, try adding a basic rule,

Such as adding a title very clear rule, so that you can see your written rule matches the request.

You can also turn on debug in the error log to get some debugging information on printing from Charles Error Log Window menu access.

Rewrite rules rewrite rule

Each rule describes a single overwrite operation.


Type Type
Type specifies the type of operation to perform rewriting. There are four different types of Rewrite Rules categories;

Title rules,

URL rules,

Query parameters rule,

Response status rules and text rules.

Head query parameters and rules are affecting header fields and query string parameters; add, modify, or delete headers and parameters.

URL and the main rules of implementation of the Find and Replace URL and different parts of the body. Rule execution state in response to find and replace the response status code and description,

E.g. 200 OK

Where

Selecting the rewrite rule position; request, response, or both.

Match

Matching text field contains a request or response to be matched, in order to determine whether to trigger the rule. You can name or value blank or while preserving, to match any value.

If you have the name and value fields blank, you will match all request / response.

You can enable regular expression support, to provide you with Perl-style regular expression matching. If you include the group in the regular expression, you can use them in the matching field.
Unless a regular expression is enabled, otherwise the field is exactly matching field name, in this case, it supports partial matching. Name field for the regular expression matching are case-insensitive and normal. If you want to create unnecessary rewrite rule type, you may disable the Name field.

Value field is part of the match, unless you open the match integer value, in this case, it is the exact match. Value field for the regular expression and matched normal rules headers and query parameters are not case-sensitive and case-insensitive URL and the text of the rules.

New / replacement

The new / replacement add or replace field contains a request or response is triggered when the text of this rule. The blank value or name, so that they match with the same name or value.

If matching regular expression support is enabled, you can use $ 1, $ 2, etc. reference group match.

Conduct field name and value depends on matching. If a corresponding match exists, then the field will be matched as an alternative text, or if the matching is empty, then the field will replace the entire name or value.

Replace the first value of the field to support or replace all modes. If the names match a regular expression, the name field is always running to replace the priority mode, otherwise it is exact match and replace the entire name.

If you want to create unnecessary rewrite rule type, you can disable field name or value.

Suggest

If you do not work as expected, rewrite rules can be difficult to debug. Regular testing, it is best to slowly build a rule.

I rarely use this, usually on some requests have been modified again; then repeat;
herein by reference: https://www.axihe.com/

Guess you like

Origin www.cnblogs.com/broszhu/p/11556618.html