美文网首页
翻译Rewrite Tool

翻译Rewrite Tool

作者: 葶寳寳 | 来源:发表于2018-09-24 19:56 被阅读0次

    第一次翻译,有译不准的地方请多指正。
    原文https://www.charlesproxy.com/documentation/tools/rewrite/

    Rewrite Tool

      The Rewrite tool enables you to create rules that modify requests and 
      responses as they pass through Charles. Rules such as adding or 
      changing a header or search and replace some text in the response 
      body.
    

    你可以用Charles Rewrite功能来重写通过Charles的请求和响应规则:比如添加或修改header、查找并且替换响应中的一些内容。

    Rewrite Sets

     Rewrite sets can be individually activated and deactivated. Each set 
     contains a list of locations and rules. The locations choose the requests 
     and responses on which the rules will operate.
    

    Rewrite设置可以单个的使用或停用。每个设置包含一系列的locationsrules,为指定的locations添加Rewrite规则。

    Rewrite Rules

     Each rule describes a single rewrite operation. The rule may affect the 
     headers, the body, or parts of the request URL; it may operate on the 
     request and or the response; it may then define search and replace or 
     just replace style rewriting.
    

    每个规则对应一个单一的Rewrite操作。这个规则可以修改headersbody或部分请求的URL,可以用作于请求也可以是响应,可以添加限制条件来修改部分请求或响应也可以直接修改所有的。

    Type

     The type specifies the type of rewriting operation to perform. There are 
     four different categories of rewrite rule types; header rules, URL rules, 
     query parameter rules, and body rules. The header and query 
     parameter rules affect the header fields and query string parameters 
     respectively; adding, modifying or removing headers and parameters. 
     The URL and body rules perform find and replace on the different parts 
     of the URL and on the body.
    

    需要指定执行Rewrite操作的类型。有四种不同的Rewrite类别,分别是header规则、URL规则、query parameter规则和body规则。headerquery parameter规则分别影响header字段和query参数,可以添加、修改或者删除headerparameterURLbody rules规则在URL的不同部分和body上执行查找和替换。

    Where

     Choose where to apply the rewrite rule; on the request, response or both.
    

    选择运用重写规则的位置:在请求、响应或两者上。

    Match

    The match fields contain the text to match in the request or response to 
    decide whether to fire this rule. You can optionally leave the name or 
    value blank, or both, to match any value. If you leave both the name 
    and value fields blank you will match all requests / responses.
    

    Match部分包含在请求或响应中匹配的文本,以决定是否运用该规则。你可以选择不填namevalue,您可以选择将名称或值留空,或两者都保留,以匹配任何值。如果namevalue字段都为空,则匹配所有请求/响应。

     Regex support may be enabled, providing Perl-style regular 
     expressions for your match. If you include groups in your regular 
     expression they may be used in the match fields.
    

    可以启用Regex支持,为匹配提供perl样式的正则表达式。如果在正则表达式中包含组,则它们可能在match字段中使用。

     The name field is an exact match field unless regex is enabled, in 
     which case it supports partial matches. The name field is case- 
     insensitive for both regex and normal matching. The name field may be 
     disabled if you are creating a rewrite rule type that doesn't require it.
    

    如果不启用regex, name字段就是一个完全匹配字段,在这种情况下,它支持部分匹配。name字段对正则表达式和普通匹配都不区分大小写。如果正在创建不需要重写规则类型,则名称字段可能被禁用。

     The value field is a partial match unless you turn on Match whole value 
     in which case it is an exact match. The value field is case-insensitive 
     for both regex and normal matching for header and query parameter 
     rules, and case-sensitive for URL and body rules.
    

    除非你勾选了Match whole value,否则value字段是部分匹配。在这种情况下,它是一个精确的匹配。对于value字段,在headerquery parameter规则中,正则表达式和常规匹配不区分大小写,而在URLbody规则中区分。

    New/Replace

     The new/replace fields contain the text to add or replace in the request 
     or response when this rule is fired. Leave either the name or value 
     blank to leave them the same as the matched name or value.
    

    New/Replace字段包含在触发此规则时要在请求或响应中添加或替换的文本。将名称或值留空,使它们与匹配的名称或值保持相同。

     If regex support is enabled for the match you may reference match 
     groups using $1, $2 and so on.
    

    如果为匹配启用了regex支持,则可以使用$1$2等引用匹配组。

     The behaviour of the name and value fields depends upon the match. If 
     there is a corresponding match then the field acts as a replacement for 
     the matched text, otherwise if the match is blank then the fields 
     replaces the whole name or value.
    

    namevalue字段的行为取决于匹配。如果有一个相应的匹配,然后该字段作为替代匹配的文本,否则如果匹配为空,则为字段替换整个名称或值。

     The value field supports Replace First or Replace All modes. The 
     name field always operates in replace-first mode if the name match is a 
     regex, otherwise it is an exact match and replaces the whole name.
    

    value字段支持替换第一个或替换所有模式。如果name匹配是正则表达式,则name字段始终替换第一个,否则它就是精确匹配并替换整个name

     The name and or value fields may be disabled if you are creating a 
     rewrite rule type that doesn't require them.
    

    可以将namevalue字段禁掉,如果在创建一个不需要他们的rewrite规则类型时。

    Recommendations

     Rewrite rules can be difficult to debug if they are not working as you 
     expect. It is often best to build up a rule slowly with frequent testing.
    

    rewrite规则很难进行调试,如果他们没有按你期望的运行。通常最好通过频繁测试来慢慢建立规则。

    Location Matching

     Each location match may contain protocol, host, port and path patterns 
     to match specific URLs. Locations may include wildcards. More help for 
     creating location matches may be found when you add a new location 
     to this tool.
    

    每个地址匹配可以包含协议、主机、端口和路径模式,去匹配特定的URL。地址可以包括通配符。当你为该工具添加新地址时,可能会发现更多关于创建位置匹配的帮助。

    Debugging

     The Rewrite tool can be difficult to debug when your rewrite operation 
     isn't working as expected. If you have trouble try including a very basic 
     rule such as one that adds an obvious header, so you can see whether 
     your rules are matching the request at all. Also turn on Debug in Error 
     Log to get some debugging information printed in the Error Log 
     accessed from the Window menu in Charles.
    

    Rewrite tool很难调试,当你的重写操作没有按预期工作时。如果您遇到困难,可以尝试一个非常基本的规则,比如添加一个明显的头部规则,这样你就可以看到你的规则是否与请求完全匹配。还可以在错误日志中打开Debug,以从Charles中的窗口菜单中获取在错误日志中打印的调试信息。

    相关文章

      网友评论

          本文标题:翻译Rewrite Tool

          本文链接:https://www.haomeiwen.com/subject/aatinftx.html