|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
HTTP服务器响应结构 更多...
#include <http_server_message.hpp>
Public 成员函数 | |
| http_server_response () | |
| 默认构造函数 | |
| NEFORCE_NODISCARD string_view | header (const string &name) const noexcept |
| 获取响应头值 | |
| void | set_header (const string &name, string value) |
| 设置响应头 | |
| NEFORCE_NODISCARD bool | has_header (const string &name) const noexcept |
| 检查响应头是否存在 | |
| void | set_content_type (http_content value) |
| 设置Content-Type | |
| void | set_content_type (string value) |
| 设置Content-Type | |
| NEFORCE_NODISCARD string | to_string () const |
| 序列化为HTTP响应字符串 | |
| Public 成员函数 继承自 istringify< http_server_response > | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string | to_string () const |
| 转换为字符串 | |
Public 属性 | |
| string | version {"HTTP/1.1"} |
| HTTP版本 | |
| http_status | status = http_status::S4_NOT_FOUNT |
| HTTP状态码 | |
| string | status_message {} |
| 状态消息 | |
| unordered_map< string, string > | headers |
| 响应头 | |
| vector< http_cookie > | cookies |
| 设置的Cookie | |
| string | body {} |
| 响应正文 | |
| string | redirect_url {} |
| 重定向URL | |
| string | forward_path {} |
| 转发路径 | |
HTTP服务器响应结构
表示一个HTTP响应,包含状态行、头部和正文。 支持重定向、Cookie设置、内容类型设置等。
使用示例:
在文件 http_server_message.hpp 第 267 行定义.
|
inline |
默认构造函数
设置默认Content-Type为text/plain,Connection为close。
在文件 http_server_message.hpp 第 282 行定义.
引用了 headers, http_content::PLAIN_TEXT() , 以及 http_content::to_string().
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
| NEFORCE_NODISCARD string http_server_response::to_string | ( | ) | const |
序列化为HTTP响应字符串
支持正常响应和重定向响应。 自动添加Content-Length头。