静态文件服务过滤器
更多...
#include <http_filter.hpp>
静态文件服务过滤器
提供静态文件服务功能,当请求匹配文件路径时返回文件内容。
在文件 http_filter.hpp 第 221 行定义.
◆ static_file_filter()
| static_file_filter::static_file_filter |
( |
string | root_path | ) |
|
|
explicit |
◆ add_mime_type()
| void static_file_filter::add_mime_type |
( |
const string & | extension, |
|
|
http_content | content_type ) |
添加MIME类型映射
- 参数
-
| extension | 文件扩展名 |
| content_type | MIME类型 |
◆ do_filter()
◆ get_mime_type()
获取MIME类型
- 参数
-
- 返回
- MIME类型,未找到返回none
◆ is_safe_path()
| NEFORCE_NODISCARD bool static_file_filter::is_safe_path |
( |
const string & | path | ) |
|
|
static |
检查路径是否安全
- 参数
-
- 返回
- 安全返回true
防止路径遍历攻击,拒绝包含".."或"//"的路径。
◆ name()
| NEFORCE_NODISCARD string static_file_filter::name |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ pre_filter()
预处理方法
- 参数
-
| request | HTTP请求 |
| response | HTTP响应 |
- 返回
- 返回false表示中断后续处理
在请求处理前调用,可以检查请求、修改请求或提前返回响应。
重载 http_filter .
该类的文档由以下文件生成: