1#ifndef NEFORCE_NETWORK_HTTP_HTTP_CONSTANTS_HPP__
2#define NEFORCE_NETWORK_HTTP_HTTP_CONSTANTS_HPP__
17NEFORCE_BEGIN_NAMESPACE__
441NEFORCE_API
string http_status_message(
http_status status);
454 string content_{
"UNKNOWN"};
457 http_content() =
default;
458 http_content(
const http_content&) =
default;
459 http_content& operator=(
const http_content&) =
default;
466 content_(_NEFORCE
move(other.content_)) {}
473 http_content&
operator=(http_content&& other)
noexcept {
477 content_ = _NEFORCE
move(other.content_);
512 NEFORCE_NODISCARD
bool is_html_text()
const {
return content_ ==
HTML_TEXT().content_; }
513 NEFORCE_NODISCARD
bool is_xml_text()
const {
return content_ == XML_TEXT().content_; }
514 NEFORCE_NODISCARD
bool is_css_text()
const {
return content_ == CSS_TEXT().content_; }
515 NEFORCE_NODISCARD
bool is_plain_text()
const {
return content_ == PLAIN_TEXT().content_; }
516 NEFORCE_NODISCARD
bool is_json_app()
const {
return content_ == JSON_APP().content_; }
517 NEFORCE_NODISCARD
bool is_form_app()
const {
return content_ == FORM_APP().content_; }
518 NEFORCE_NODISCARD
bool is_jpeg_img()
const {
return content_ == JPEG_IMG().content_; }
519 NEFORCE_NODISCARD
bool is_png_img()
const {
return content_ == PNG_IMG().content_; }
520 NEFORCE_NODISCARD
bool is_bmp_img()
const {
return content_ == BMP_IMG().content_; }
521 NEFORCE_NODISCARD
bool is_webp_img()
const {
return content_ == WEBP_IMG().content_; }
522 NEFORCE_NODISCARD
bool is_html_msg()
const {
return content_ == HTML_MSG().content_; }
524 NEFORCE_NODISCARD
static bool is_html_text(
const string_view view) {
return view == HTML_TEXT().content_; }
525 NEFORCE_NODISCARD
static bool is_xml_text(
const string_view view) {
return view == XML_TEXT().content_; }
526 NEFORCE_NODISCARD
static bool is_css_text(
const string_view view) {
return view == CSS_TEXT().content_; }
527 NEFORCE_NODISCARD
static bool is_plain_text(
const string_view view) {
return view == PLAIN_TEXT().content_; }
528 NEFORCE_NODISCARD
static bool is_json_app(
const string_view view) {
return view == JSON_APP().content_; }
529 NEFORCE_NODISCARD
static bool is_form_app(
const string_view view) {
return view == FORM_APP().content_; }
530 NEFORCE_NODISCARD
static bool is_jpeg_img(
const string_view view) {
return view == JPEG_IMG().content_; }
531 NEFORCE_NODISCARD
static bool is_png_img(
const string_view view) {
return view == PNG_IMG().content_; }
532 NEFORCE_NODISCARD
static bool is_bmp_img(
const string_view view) {
return view == BMP_IMG().content_; }
533 NEFORCE_NODISCARD
static bool is_webp_img(
const string_view view) {
return view == WEBP_IMG().content_; }
534 NEFORCE_NODISCARD
static bool is_html_msg(
const string_view view) {
return view == HTML_MSG().content_; }
540 NEFORCE_NODISCARD
const string&
content() const& noexcept {
return content_; }
546 NEFORCE_NODISCARD
string content() &&
noexcept {
return _NEFORCE
move(content_); }
552 NEFORCE_NODISCARD
string to_string()
const {
return content_; }
568 string method_{
"UNKNOWN"};
571 http_method() =
default;
572 http_method(
const http_method&) =
default;
573 http_method& operator=(
const http_method&) =
default;
580 method_(_NEFORCE
move(other.method_)) {}
591 method_ = _NEFORCE
move(other.method_);
631 static const http_method&
GET();
632 static const http_method&
POST();
633 static const http_method&
HEAD();
634 static const http_method&
PUT();
646 NEFORCE_NODISCARD
const string&
method() const& noexcept {
return method_; }
652 NEFORCE_NODISCARD
string method() &&
noexcept {
return _NEFORCE
move(method_); }
661 NEFORCE_NODISCARD http_method
operator&(
const http_method& rhs)
const& {
662 return http_method(method_ +
", " + rhs.method_);
669 NEFORCE_NODISCARD http_method operator&(
const http_method& rhs) && {
670 return http_method(_NEFORCE
move(method_) +
", " + rhs.method_);
673 NEFORCE_NODISCARD http_method operator&(http_method&& rhs) && {
674 return http_method(_NEFORCE
move(method_) +
", " + _NEFORCE
move(rhs.method_));
677 NEFORCE_NODISCARD
bool is_get()
const {
return method_ == GET().method_; }
678 NEFORCE_NODISCARD
bool is_post()
const {
return method_ == POST().method_; }
679 NEFORCE_NODISCARD
bool is_head()
const {
return method_ == HEAD().method_; }
680 NEFORCE_NODISCARD
bool is_put()
const {
return method_ == PUT().method_; }
681 NEFORCE_NODISCARD
bool is_delete()
const {
return method_ ==
DELETE().method_; }
682 NEFORCE_NODISCARD
bool is_options()
const {
return method_ == OPTIONS().method_; }
683 NEFORCE_NODISCARD
bool is_trace()
const {
return method_ ==
TRACE().method_; }
684 NEFORCE_NODISCARD
bool is_connect()
const {
return method_ == CONNECT().method_; }
685 NEFORCE_NODISCARD
bool is_patch()
const {
return method_ == PATCH().method_; }
691 NEFORCE_NODISCARD
string to_string()
const {
return method_; }
701struct NEFORCE_API http_cookie_name :
istringify<http_cookie_name> {
703 string cookie_{
"UNKNOWN"};
706 http_cookie_name() =
default;
707 http_cookie_name(
const http_cookie_name&) =
default;
708 http_cookie_name& operator=(
const http_cookie_name&) =
default;
715 cookie_(_NEFORCE
move(other.cookie_)) {}
722 http_cookie_name&
operator=(http_cookie_name&& other)
noexcept {
726 cookie_ = _NEFORCE
move(other.cookie_);
735 cookie_(
move(cookie)) {}
758 NEFORCE_NODISCARD
const string&
cookie_name() const& noexcept {
return cookie_; }
770 NEFORCE_NODISCARD
string to_string()
const {
return cookie_; }
774struct NEFORCE_API http_key {
775 static const string& Access_Control_Allow_Credentials();
776 static const string& Access_Control_Allow_Headers();
777 static const string& Access_Control_Allow_Methods();
778 static const string& Access_Control_Allow_Origin();
779 static const string& Access_Control_Max_Age();
780 static const string& Connection();
781 static const string& Content_Length();
782 static const string& Content_Type();
783 static const string& Lax();
784 static const string& Strict();
785 static const string& X_Forwarded_Proto();
791NEFORCE_END_NAMESPACE__
constexpr T * addressof(T &x) noexcept
获取对象的地址
unsigned short uint16_t
16位无符号整数类型
#define NEFORCE_ERROR_BUILD_FINAL_CLASS(THIS, BASE, INFO)
构建最终异常类宏
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
basic_string_view< char > string_view
字符字符串视图
@ S5_HTTP_VERSION_NOT_SUPPORTED
505 HTTP Version Not Supported 不支持的HTTP版本
@ S5_GATEWAY_TIMEOUT
504 Gateway Timeout 上游服务器响应超时
@ S5_BAD_GATEWAY
502 Bad Gateway 上游服务器响应无效
@ S5_INTERNAL_SERVER_ERROR
500 Internal Server Error 服务器内部错误
@ S1_SWITCHING_PROTOCOLS
101 Switching Protocols 同意切换协议
@ S4_UNAUTHORIZED
401 Unauthorized 需要身份验证
@ S4_METHOD_NOT_ALLOWED
405 Method Not Allowed 请求方法不允许
@ S4_FORBIDDEN
403 Forbidden 服务器拒绝请求
@ S4_UNAVAILABLE_FOR_LEGAL_REASONS
451 Unavailable For Legal Reasons 因法律原因不可用
@ S1_CONTINUE
100 Continue 服务器收到请求头,客户端可以继续发送请求体
@ S4_EXPECTATION_FAILED
417 Expectation Failed 无法满足Expect请求头
@ S3_NOT_MODIFIED
304 Not Modified 资源未修改,可使用本地缓存
@ S2_CREATED
201 Created 请求成功并创建了新资源
@ S4_URI_TOO_LONG
414 URI Too Long 请求URL过长
@ S4_UNSUPPORTED_MEDIA_TYPE
415 Unsupported Media Type 不支持的媒体格式
@ S5_NOT_IMPLEMENTED
501 Not Implemented 服务器不支持该请求功能
@ S2_PARTIAL_CONTENT
206 Partial Content 部分请求成功(范围请求)
@ S3_MOVED_PERMANENT
301 Moved Permanently 资源已永久迁移到新URL
@ S4_CONFLICT
409 Conflict 请求与资源当前状态冲突
@ S4_TOO_MANY_REQUESTS
429 Too Many Requests 请求次数过多
@ S4_LENGTH_REQUIRED
411 Length Required 请求未指定Content-Length
@ S4_PRECONDITION_FAILED
412 Precondition Failed 请求先决条件未满足
@ S5_SERVICE_UNAVAILABLE
503 Service Unavailable 服务暂时不可用
@ S2_NO_CONTENT
204 No Content 请求成功但无内容返回
@ S4_UNPROCESSABLE_CONTENT
422 Unprocessable Content 请求格式正确但语义有误
@ S4_UPGRADE_REQUIRED
426 Upgrade Required 需要升级协议
@ S4_HEADER_FIELDS_TOO_LARGE
431 Request Header Fields Too Large 请求头字段过大
@ S3_FOUND
302 Found 资源临时迁移到新URL
@ S4_NOT_FOUND
404 Not Found 请求的资源不存在
@ S2_ACCEPTED
202 Accepted 请求已接受但尚未处理
@ S4_RANGE_NOT_SATISFIABLE
416 Range Not Satisfiable 无法满足Range请求
@ S4_PAYLOAD_TOO_LARGE
413 Payload Too Large 请求体过大
@ S4_BAD_REQUEST
400 Bad Request 请求格式错误
@ S3_TEMPORARY_REDIRECT
307 Temporary Redirect 临时重定向
@ S4_PROXY_AUTH_REQUIRED
407 Proxy Authentication Required 需要通过代理认证
@ S3_PERMANENT_REDIRECT
308 Permanent Redirect 永久重定向
@ S4_NOT_ACCEPTABLE
406 Not Acceptable 无法生成匹配Accept头的内容
@ S4_GONE
410 Gone 资源已永久删除
@ S4_REQUEST_TIMEOUT
408 Request Timeout 客户端请求超时
@ S3_SEE_OTHER
303 See Other 重定向到另一个URI获取响应
static const http_content & FORM_APP()
application/x-www-form-urlencoded
http_content & operator=(http_content &&other) noexcept
移动赋值运算符
static const http_content & XML_TEXT()
text/xml
static const http_content & PLAIN_TEXT()
text/plain
string to_string() const
转换为字符串
static const http_content & JSON_APP()
application/json
static const http_content & JPEG_IMG()
image/jpeg
http_content(string content)
字符串构造函数
http_content(http_content &&other) noexcept
移动构造函数
const string & content() const &noexcept
获取左值内容
static const http_content & HTML_MSG()
message/html
string content() &&noexcept
获取右值内容
static const http_content & HTML_TEXT()
text/html
http_content & operator=(const string &content)
字符串赋值运算符
static const http_content & WEBP_IMG()
image/webp
static const http_content & CSS_TEXT()
text/css
static const http_content & BMP_IMG()
image/bmp
static const http_content & PNG_IMG()
image/png
string cookie_name() &&noexcept
获取右值Cookie名称
string to_string() const
转换为字符串
static const http_cookie_name & ASPSESSIONID()
ASP会话ID
http_cookie_name & operator=(const string &cookie)
字符串赋值运算符
static const http_cookie_name & JSESSIONID()
Java/JSP会话ID
http_cookie_name(string cookie)
字符串构造函数
http_cookie_name & operator=(http_cookie_name &&other) noexcept
移动赋值运算符
static const http_cookie_name & SESSIONID()
通用会话ID
static const http_cookie_name & PHPSESSID()
PHP会话ID
const string & cookie_name() const &noexcept
获取左值Cookie名称
http_cookie_name(http_cookie_name &&other) noexcept
移动构造函数
static const http_method & CONNECT()
CONNECT方法
http_method & operator=(const string &method)
左值字符串赋值运算符
static const http_method & HEAD()
HEAD方法
string to_string() const
转换为字符串
http_method(const string &method)
左值字符串构造函数
static const http_method & PUT()
PUT方法
http_method & operator=(string &&method)
右值字符串赋值运算符
static const http_method & DELETE()
DELETE方法
static const http_method & DEFAULT()
默认方法
http_method operator&(const http_method &rhs) const &
方法组合操作符
static const http_method & POST()
POST方法
const string & method() const &noexcept
获取左值方法
static const http_method & OPTIONS()
OPTIONS方法
static const http_method & TRACE()
TRACE方法
string method() &&noexcept
获取右值方法
http_method(http_method &&other) noexcept
移动构造函数
static const http_method & PATCH()
PATCH方法
http_method & operator=(http_method &&other) noexcept
移动赋值运算符
http_method(string &&method)
右值字符串构造函数
static const http_method & GET()
GET方法