![]() |
RMVL
2.6.0-dev
Robotic Manipulation and Vision Library
|
HTTP 响应结构 更多...
#include <rmvl/io/netapp.hpp>
Public 成员函数 | |
| std::string | generate () |
| 生成 HTTP 响应报文 | |
| Response & | attachment (std::string_view filename) |
| 设置附件响应头 Content-Disposition,一般需要配合 send() 或 sendFile() 使用 | |
| Response & | download (std::string_view path, std::string_view filename="", std::function< void(bool)> fn=nullptr) |
| 设置附件响应头 Content-Disposition 并发送文件内容作为响应 | |
| Response & | get (std::string_view head) |
| 返回指定的 HTTP 响应头 | |
| Response & | json (const ::rm::json &j) |
| 发送 JSON 格式的响应数据 | |
| Response & | redirect (std::string_view url) |
| 发送重定向响应 | |
| Response & | redirect (uint16_t code, std::string_view url) |
| 重定向响应 | |
| Response & | send (std::string_view str) |
| 发送响应数据 | |
| Response & | sendFile (std::string_view file) |
| 发送文件内容作为响应 | |
| Response & | set (std::string_view key, std::string_view value) |
| 设置响应头 | |
| Response & | status (uint16_t code) |
| 设置响应的 HTTP 状态,注意此方法会覆盖原有状态 | |
| operator bool () const noexcept | |
静态 Public 成员函数 | |
| static Response | parse (std::string_view str) |
| 解析 HTTP 响应 | |
Public 属性 | |
| uint16_t | state {} |
| 响应行:状态码 | |
| std::string | message {} |
| 响应行:状态消息 | |
| std::unordered_map< std::string, std::string > | heads {} |
| 响应头 | |
| std::string | body {} |
| 响应数据 | |
HTTP 响应结构
| Response & rm::Response::attachment | ( | std::string_view | filename | ) |
设置附件响应头 Content-Disposition,一般需要配合 send() 或 sendFile() 使用
| [in] | filename | 附件文件名 |
| Response & rm::Response::download | ( | std::string_view | path, |
| std::string_view | filename = "", | ||
| std::function< void(bool)> | fn = nullptr ) |
设置附件响应头 Content-Disposition 并发送文件内容作为响应
| [in] | path | 路径 |
| [in] | filename | 附件文件名 |
| [in] | fn | 发送完成后的回调函数,参数表示是否发送成功 |
| std::string rm::Response::generate | ( | ) |
生成 HTTP 响应报文
| Response & rm::Response::get | ( | std::string_view | head | ) |
| Response & rm::Response::json | ( | const ::rm::json & | j | ) |
|
inlinenoexcept |
|
static |
解析 HTTP 响应
| [in] | str | HTTP 响应报文 |
|
inline |
| Response & rm::Response::redirect | ( | uint16_t | code, |
| std::string_view | url ) |
| Response & rm::Response::send | ( | std::string_view | str | ) |
| Response & rm::Response::sendFile | ( | std::string_view | file | ) |
| Response & rm::Response::set | ( | std::string_view | key, |
| std::string_view | value ) |
| Response & rm::Response::status | ( | uint16_t | code | ) |
| std::string rm::Response::body {} |
响应数据
| std::unordered_map<std::string, std::string> rm::Response::heads {} |
响应头
| std::string rm::Response::message {} |
响应行:状态消息
| uint16_t rm::Response::state {} |
响应行:状态码