Skip to content

attachment

设置响应头 content-disposition 字段,可以让请求直接变下载。

类似 Koa 的 attachment 方法:https://koajs.com/

规则语法

txt
pattern attachment://filename [filters...]
参数描述详细文档
pattern匹配请求 URL 的表达式匹配模式文档
filename下载后显示的文件名称,如 test.txt
• 内联/内嵌/Values内容
⚠️ 不支持从文件/远程 URL 加载数据
filters可选过滤器,支持匹配:
• 请求URL/方法/头部/内容
• 响应状态码/头部
过滤器文档

配置示例

txt
https://www.example.com/ attachment://example.html

浏览器访问 https://www.example.com/ 自动下载 example.html 文件。

关联协议

  1. 直接修改请求头:resHeaders://content-disposition=attachment;filename="example.html"