Skip to content

resType

修改响应头 content-typemedia-typecharset 部分。

content-type 结构:

txt
<media-type>; charset=<encoding>

规则语法

txt
pattern resType://type[;charset] [filters...]
参数描述详细文档
pattern匹配请求 URL 的表达式匹配模式文档
type[;charset]type 响应类型,charset 编码
• 内联/内嵌/Values内容
⚠️ 不支持从文件/远程 URL 加载数据
filters可选过滤器,支持匹配:
• 请求URL/方法/头部/内容
• 响应状态码/头部
过滤器文档

resType 主要用来修改响应类型的 media-type 部分 ,charset 部分可选,如果没有设置 charset 部分则会保留响应头原始的 charset 部分(如果存在)。

配置示例

快捷命令(不包含 / 的字符串)

根据 mime.lookup(type) 自动转换

txt
# 不带编码响应头的 `content-type` 变成 `text/html`
www.example.com/path resType://html

# 带编码响应头的 `content-type` 变成 `application/json;charset=utf8`
www.example.com/path resType://json;charset=utf8

完整类型

txt
# 响应头的 `content-type` 变成 `text/plain`
www.example.com/path resType://text/plain

# 响应头的 `content-type` 变成 `text/plain;charset=utf8`
www.example.com/path resType://text/plain;charset=utf8

关联协议

  1. 直接修改响应头:resHeaders://content-type=xxx
  2. 修改响应内容编码:resCharset://encoding