1#ifndef NEFORCE_NETWORK_HTTP_HTTP_SERVER_MESSAGE_HPP__
2#define NEFORCE_NETWORK_HTTP_HTTP_SERVER_MESSAGE_HPP__
23NEFORCE_BEGIN_NAMESPACE__
92 return it !=
parameters.end() ? it->second.view() :
"";
116 return it !=
cookies.end() ? it->second.view() :
"";
140 return it !=
headers.end() ? it->second.view() :
"";
174 const auto conn =
header(http_key::Connection());
175 return conn ==
"keep-alive" || conn ==
"Keep-Alive";
205 NEFORCE_NODISCARD
bool is_ajax()
const {
return header(
"X-Requested-With") ==
"XMLHttpRequest"; }
282 headers[http_key::Connection()] =
"close";
292 return it !=
headers.end() ? it->second.view() :
"";
346NEFORCE_END_NAMESPACE__
http_server_response http_response
HTTP响应类型别名
http_server_request http_request
HTTP请求类型别名
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
basic_string_view< char > string_view
字符字符串视图
bool name(char *buffer, size_t size)
获取当前线程名称
@ S4_NOT_FOUND
404 Not Found 请求的资源不存在
static const http_content & PLAIN_TEXT()
text/plain
string to_string() const
转换为字符串
static const http_method & GET()
GET方法
string_view referer() const
获取Referer
void set_parameter(const string &name, string value)
设置参数
string_view parameter(const string &name) const
获取参数值
string_view user_agent() const
获取User-Agent
bool has_parameter(const string &name) const
检查参数是否存在
string_view content_type() const
获取Content-Type
unordered_map< string, string > headers
请求头
string to_string() const
序列化为HTTP请求字符串
string_view cookie(const string &name) const
获取Cookie值
bool is_keep_alive() const
检查是否为Keep-Alive连接
http_session * session
会话对象
void set_cookie(const string &name, string value)
设置Cookie值
bool is_ajax() const
检查是否为AJAX请求
bool has_header(const string &name) const
检查请求头是否存在
string_view header(const string &name) const
获取请求头值
unordered_map< string, string > form_data
表单数据
string_view client_ip() const
获取客户端真实IP
bool has_cookie(const string &name) const
检查Cookie是否存在
static http_server_request parse(string_view str)
从字符串解析HTTP请求
unordered_map< string, string > cookies
Cookie
void set_header(const string &name, string value)
设置请求头
unordered_map< string, string > parameters
请求参数
bool has_session() const noexcept
检查是否有关联的有效会话
http_status status
HTTP状态码
void set_content_type(http_content value)
设置Content-Type
string redirect_url
重定向URL
string_view header(const string &name) const
获取响应头值
unordered_map< string, string > headers
响应头
string to_string() const
序列化为HTTP响应字符串
void set_header(const string &name, string value)
设置响应头
string status_message
状态消息
vector< http_cookie > cookies
设置的Cookie
void set_content_type(string value)
设置Content-Type
http_server_response()
默认构造函数
bool has_header(const string &name) const
检查响应头是否存在