SNode.C
Loading...
Searching...
No Matches
StatusCodes.cpp
Go to the documentation of this file.
1
/*
2
* SNode.C - a slim toolkit for network communication
3
* Copyright (C) Volker Christian <me@vchrist.at>
4
* 2020, 2021, 2022, 2023, 2024, 2025
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published
8
* by the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#
include
"web/http/StatusCodes.h"
21
22
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
23
24
#
include
<
utility
>
25
26
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
27
28
namespace
web::http {
29
30
std::map<
int
, std::string> StatusCode::statusCode = {{100,
"Continue"
},
31
{101,
"Switching Protocols"
},
32
{102,
"Processing"
},
33
{103,
"Early Hints"
},
34
{200,
"OK"
},
35
{201,
"Created"
},
36
{202,
"Accepted"
},
37
{203,
"Non-Authoritative Information"
},
38
{204,
"No Content"
},
39
{205,
"Reset Content"
},
40
{206,
"Partial Content"
},
41
{207,
"Multi-Status"
},
42
{208,
"Already Reported"
},
43
{226,
"IM Used"
},
44
{300,
"Multiple Choices"
},
45
{301,
"Moved Permanently"
},
46
{302,
"Found"
},
47
{303,
"See Other"
},
48
{304,
"Not Modified"
},
49
{305,
"Use Proxy"
},
50
{307,
"Temporary Redirect"
},
51
{308,
"Permanent Redirect"
},
52
{400,
"Bad Request"
},
53
{401,
"Unauthorized"
},
54
{402,
"Payment Required"
},
55
{403,
"Forbidden"
},
56
{404,
"Not Found"
},
57
{405,
"Method Not Allowed"
},
58
{406,
"Not Acceptable"
},
59
{407,
"Proxy Authentication Required"
},
60
{408,
"Request Timeout"
},
61
{409,
"Conflict"
},
62
{410,
"Gone"
},
63
{411,
"Length Required"
},
64
{412,
"Precondition Failed"
},
65
{413,
"Payload Too Large"
},
66
{414,
"URI Too Long"
},
67
{415,
"Unsupported Media Type"
},
68
{416,
"Range Not Satisfiable"
},
69
{417,
"Expectation Failed"
},
70
{421,
"Misdirected Request"
},
71
{422,
"Unprocessable Entity"
},
72
{423,
"Locked"
},
73
{424,
"Failed Dependency"
},
74
{425,
"Too Early"
},
75
{426,
"Upgrade Required"
},
76
{427,
"Unassigned"
},
77
{428,
"Precondition Required"
},
78
{429,
"Too Many Requests"
},
79
{430,
"Unassigned"
},
80
{431,
"Request Header Fields Too Large"
},
81
{451,
"Unavailable For Legal Reasons"
},
82
{500,
"Internal Server Error"
},
83
{501,
"Not Implemented"
},
84
{502,
"Bad Gateway"
},
85
{503,
"Service Unavailable"
},
86
{504,
"Gateway Timeout"
},
87
{505,
"HTTP Version Not Supported"
},
88
{506,
"Variant Also Negotiates"
},
89
{507,
"Insufficient Storage"
},
90
{508,
"Loop Detected"
},
91
{510,
"Not Extended"
},
92
{511,
"Network Authentication Required"
}};
93
94
std::string StatusCode::reason(
int
status) {
95
std::string reasonPhrase =
"unknown status code"
;
96
97
if
(StatusCode::contains(status)) {
98
reasonPhrase = statusCode[status];
99
}
100
101
return
reasonPhrase;
102
}
103
104
bool
StatusCode::contains(
int
status) {
105
return
statusCode.contains(status);
106
}
107
}
// namespace web::http
web
http
StatusCodes.cpp
Generated on Mon Feb 10 2025 20:22:05 for SNode.C by
1.11.0