resType

修改响应头的content-type,配置方式:

  1. pattern resType://mimeType

pattern参见匹配模式,更多模式请参考配置方式,mimeType为新的content-type,如:text/plaintext/htmlimage/png等等,还有一些后缀关键字,whistle会自动把它转成对应的type:

  1. json: application/json
  2. xml: text/xml
  3. js: text/javascript
  4. txt: text/plain
  5. html: text/html

等等

例子:

  1. www.ifeng.com resType://text

过滤规则

需要确保whistle是最新版本:更新whistle

如果要过滤指定请求或指定协议的规则匹配,可以用如下协议:

  1. ignore:忽略指定规则
  2. filter:过滤指定pattern,支持根据请求方法、请求头、请求客户端IP过滤

例子:

  1. # 下面表示匹配pattern的同时不能为post请求且请求头里面的cookie字段必须包含test(忽略大小写)、url里面必须包含 cgi-bin 的请求
  2. # 即:过滤掉匹配filter里面的请求
  3. pattern operator1 operator2 excludeFilter://m:post includeFilter://h:cookie=test includeFilter:///cgi-bin/i
  4. # 下面表示匹配pattern1、pattern2的请求方法为post、或请求头里面的cookie字段不能包含类似 `uin=123123` 且url里面必须包含 cgi-bin 的请求
  5. operator pattern1 pattern2 includeFilter://m:post excludeFilter://h:cookie=/uin=o\d+/i excludeFilter:///cgi-bin/i
  6. # 下面表示匹配pattern的请求忽略除了host以外的所有规则
  7. pattern ignore://*|!host
  8. # 下面表示匹配pattern的请求忽略file和host协议的规则
  9. pattern ignore://file|host