HTTP服务器响应结构
更多...
#include <http_server_message.hpp>
HTTP服务器响应结构
表示一个HTTP响应,包含状态行、头部和正文。 支持重定向、Cookie设置、内容类型设置等。
使用示例:
response.
body =
"<html><body>Hello World</body></html>";
constexpr void push_back(const T &value)
在末尾拷贝插入元素
http_cookie_name name
Cookie名称
bool http_only
HttpOnly(禁止JS)
http_status status
HTTP状态码
void set_content_type(http_content value)
设置Content-Type
string to_string() const
序列化为HTTP响应字符串
string status_message
状态消息
vector< http_cookie > cookies
设置的Cookie
http_server_response()
默认构造函数
在文件 http_server_message.hpp 第 265 行定义.
◆ http_server_response()
| http_server_response::http_server_response |
( |
| ) |
|
|
inline |
◆ has_header()
| bool http_server_response::has_header |
( |
const string & | name | ) |
const |
|
inlinenodiscard |
◆ header()
◆ set_content_type() [1/2]
| void http_server_response::set_content_type |
( |
http_content | value | ) |
|
|
inline |
◆ set_content_type() [2/2]
| void http_server_response::set_content_type |
( |
string | value | ) |
|
|
inline |
◆ set_header()
| void http_server_response::set_header |
( |
const string & | name, |
|
|
string | value ) |
|
inline |
◆ to_string()
| string http_server_response::to_string |
( |
| ) |
const |
|
nodiscard |
序列化为HTTP响应字符串
- 返回
- HTTP响应字符串
支持正常响应和重定向响应。 自动添加Content-Length头。
该结构体的文档由以下文件生成: