| 1 |
|
|
1 |
|
|
| 2 |
|
// Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com)
|
2 |
|
// Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com)
|
| 3 |
|
|
3 |
|
|
| 4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
| 5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 6 |
|
|
6 |
|
|
| 7 |
|
// Official repository: https://github.com/cppalliance/http
|
7 |
|
// Official repository: https://github.com/cppalliance/http
|
| 8 |
|
|
8 |
|
|
| 9 |
|
|
9 |
|
|
| 10 |
|
#include <boost/http/status.hpp>
|
10 |
|
#include <boost/http/status.hpp>
|
| 11 |
|
#include <boost/http/detail/except.hpp>
|
11 |
|
#include <boost/http/detail/except.hpp>
|
| 12 |
|
//#include <boost/throw_exception.hpp>
|
12 |
|
//#include <boost/throw_exception.hpp>
|
| 13 |
|
|
13 |
|
|
| 14 |
|
|
14 |
|
|
| 15 |
|
|
15 |
|
|
| 16 |
|
|
16 |
|
|
| 17 |
|
|
17 |
|
|
| 18 |
|
|
18 |
|
|
| 19 |
|
int_to_status(unsigned v)
|
19 |
|
int_to_status(unsigned v)
|
| 20 |
|
|
20 |
|
|
| 21 |
|
switch(static_cast<status>(v))
|
21 |
|
switch(static_cast<status>(v))
|
| 22 |
|
|
22 |
|
|
| 23 |
|
|
23 |
|
|
| 24 |
|
|
24 |
|
|
| 25 |
|
case status::switching_protocols:
|
25 |
|
case status::switching_protocols:
|
| 26 |
|
|
26 |
|
|
| 27 |
|
case status::early_hints:
|
27 |
|
case status::early_hints:
|
| 28 |
|
|
28 |
|
|
| 29 |
|
|
29 |
|
|
| 30 |
|
|
30 |
|
|
| 31 |
|
|
31 |
|
|
| 32 |
|
|
32 |
|
|
| 33 |
|
|
33 |
|
|
| 34 |
|
case status::non_authoritative_information:
|
34 |
|
case status::non_authoritative_information:
|
| 35 |
|
|
35 |
|
|
| 36 |
|
case status::reset_content:
|
36 |
|
case status::reset_content:
|
| 37 |
|
case status::partial_content:
|
37 |
|
case status::partial_content:
|
| 38 |
|
case status::multi_status:
|
38 |
|
case status::multi_status:
|
| 39 |
|
case status::already_reported:
|
39 |
|
case status::already_reported:
|
| 40 |
|
|
40 |
|
|
| 41 |
|
|
41 |
|
|
| 42 |
|
|
42 |
|
|
| 43 |
|
|
43 |
|
|
| 44 |
|
case status::multiple_choices:
|
44 |
|
case status::multiple_choices:
|
| 45 |
|
case status::moved_permanently:
|
45 |
|
case status::moved_permanently:
|
| 46 |
|
|
46 |
|
|
| 47 |
|
|
47 |
|
|
| 48 |
|
case status::not_modified:
|
48 |
|
case status::not_modified:
|
| 49 |
|
|
49 |
|
|
| 50 |
|
case status::temporary_redirect:
|
50 |
|
case status::temporary_redirect:
|
| 51 |
|
case status::permanent_redirect:
|
51 |
|
case status::permanent_redirect:
|
| 52 |
|
|
52 |
|
|
| 53 |
|
|
53 |
|
|
| 54 |
|
|
54 |
|
|
| 55 |
|
case status::bad_request:
|
55 |
|
case status::bad_request:
|
| 56 |
|
case status::unauthorized:
|
56 |
|
case status::unauthorized:
|
| 57 |
|
case status::payment_required:
|
57 |
|
case status::payment_required:
|
| 58 |
|
|
58 |
|
|
| 59 |
|
|
59 |
|
|
| 60 |
|
case status::method_not_allowed:
|
60 |
|
case status::method_not_allowed:
|
| 61 |
|
case status::not_acceptable:
|
61 |
|
case status::not_acceptable:
|
| 62 |
|
case status::proxy_authentication_required:
|
62 |
|
case status::proxy_authentication_required:
|
| 63 |
|
case status::request_timeout:
|
63 |
|
case status::request_timeout:
|
| 64 |
|
|
64 |
|
|
| 65 |
|
|
65 |
|
|
| 66 |
|
case status::length_required:
|
66 |
|
case status::length_required:
|
| 67 |
|
case status::precondition_failed:
|
67 |
|
case status::precondition_failed:
|
| 68 |
|
case status::payload_too_large:
|
68 |
|
case status::payload_too_large:
|
| 69 |
|
case status::uri_too_long:
|
69 |
|
case status::uri_too_long:
|
| 70 |
|
case status::unsupported_media_type:
|
70 |
|
case status::unsupported_media_type:
|
| 71 |
|
case status::range_not_satisfiable:
|
71 |
|
case status::range_not_satisfiable:
|
| 72 |
|
case status::expectation_failed:
|
72 |
|
case status::expectation_failed:
|
| 73 |
|
case status::misdirected_request:
|
73 |
|
case status::misdirected_request:
|
| 74 |
|
case status::unprocessable_entity:
|
74 |
|
case status::unprocessable_entity:
|
| 75 |
|
|
75 |
|
|
| 76 |
|
case status::failed_dependency:
|
76 |
|
case status::failed_dependency:
|
| 77 |
|
|
77 |
|
|
| 78 |
|
case status::upgrade_required:
|
78 |
|
case status::upgrade_required:
|
| 79 |
|
case status::precondition_required:
|
79 |
|
case status::precondition_required:
|
| 80 |
|
case status::too_many_requests:
|
80 |
|
case status::too_many_requests:
|
| 81 |
|
case status::request_header_fields_too_large:
|
81 |
|
case status::request_header_fields_too_large:
|
| 82 |
|
case status::unavailable_for_legal_reasons:
|
82 |
|
case status::unavailable_for_legal_reasons:
|
| 83 |
|
|
83 |
|
|
| 84 |
|
|
84 |
|
|
| 85 |
|
|
85 |
|
|
| 86 |
|
case status::internal_server_error:
|
86 |
|
case status::internal_server_error:
|
| 87 |
|
case status::not_implemented:
|
87 |
|
case status::not_implemented:
|
| 88 |
|
case status::bad_gateway:
|
88 |
|
case status::bad_gateway:
|
| 89 |
|
case status::service_unavailable:
|
89 |
|
case status::service_unavailable:
|
| 90 |
|
case status::gateway_timeout:
|
90 |
|
case status::gateway_timeout:
|
| 91 |
|
case status::http_version_not_supported:
|
91 |
|
case status::http_version_not_supported:
|
| 92 |
|
case status::variant_also_negotiates:
|
92 |
|
case status::variant_also_negotiates:
|
| 93 |
|
case status::insufficient_storage:
|
93 |
|
case status::insufficient_storage:
|
| 94 |
|
case status::loop_detected:
|
94 |
|
case status::loop_detected:
|
| 95 |
|
case status::not_extended:
|
95 |
|
case status::not_extended:
|
| 96 |
|
case status::network_authentication_required:
|
96 |
|
case status::network_authentication_required:
|
| 97 |
|
return static_cast<status>(v);
|
97 |
|
return static_cast<status>(v);
|
| 98 |
|
|
98 |
|
|
| 99 |
|
|
99 |
|
|
| 100 |
|
|
100 |
|
|
| 101 |
|
|
101 |
|
|
| 102 |
|
|
102 |
|
|
| 103 |
|
|
103 |
|
|
| 104 |
|
|
104 |
|
|
| 105 |
|
|
105 |
|
|
| 106 |
|
to_status_class(unsigned v)
|
106 |
|
to_status_class(unsigned v)
|
| 107 |
|
|
107 |
|
|
| 108 |
|
|
108 |
|
|
| 109 |
|
|
109 |
|
|
| 110 |
|
case 1: return status_class::informational;
|
110 |
|
case 1: return status_class::informational;
|
| 111 |
|
case 2: return status_class::successful;
|
111 |
|
case 2: return status_class::successful;
|
| 112 |
|
case 3: return status_class::redirection;
|
112 |
|
case 3: return status_class::redirection;
|
| 113 |
|
case 4: return status_class::client_error;
|
113 |
|
case 4: return status_class::client_error;
|
| 114 |
|
case 5: return status_class::server_error;
|
114 |
|
case 5: return status_class::server_error;
|
| 115 |
|
|
115 |
|
|
| 116 |
|
|
116 |
|
|
| 117 |
|
|
117 |
|
|
| 118 |
|
return status_class::unknown;
|
118 |
|
return status_class::unknown;
|
| 119 |
|
|
119 |
|
|
| 120 |
|
|
120 |
|
|
| 121 |
|
|
121 |
|
|
| 122 |
|
to_status_class(status v)
|
122 |
|
to_status_class(status v)
|
| 123 |
|
|
123 |
|
|
| 124 |
|
return to_status_class(static_cast<int>(v));
|
124 |
|
return to_status_class(static_cast<int>(v));
|
| 125 |
|
|
125 |
|
|
| 126 |
|
|
126 |
|
|
| 127 |
|
|
127 |
|
|
| 128 |
|
|
128 |
|
|
| 129 |
|
|
129 |
|
|
| 130 |
|
|
130 |
|
|
| 131 |
|
switch(static_cast<status>(v))
|
131 |
|
switch(static_cast<status>(v))
|
| 132 |
|
|
132 |
|
|
| 133 |
|
|
133 |
|
|
| 134 |
|
case status::continue_: return "Continue";
|
134 |
|
case status::continue_: return "Continue";
|
| 135 |
|
case status::switching_protocols: return "Switching Protocols";
|
135 |
|
case status::switching_protocols: return "Switching Protocols";
|
| 136 |
|
case status::processing: return "Processing";
|
136 |
|
case status::processing: return "Processing";
|
| 137 |
|
case status::early_hints: return "Early Hints";
|
137 |
|
case status::early_hints: return "Early Hints";
|
| 138 |
|
|
138 |
|
|
| 139 |
|
|
139 |
|
|
| 140 |
|
case status::ok: return "OK";
|
140 |
|
case status::ok: return "OK";
|
| 141 |
|
case status::created: return "Created";
|
141 |
|
case status::created: return "Created";
|
| 142 |
|
case status::accepted: return "Accepted";
|
142 |
|
case status::accepted: return "Accepted";
|
| 143 |
|
case status::non_authoritative_information: return "Non-Authoritative Information";
|
143 |
|
case status::non_authoritative_information: return "Non-Authoritative Information";
|
| 144 |
|
case status::no_content: return "No Content";
|
144 |
|
case status::no_content: return "No Content";
|
| 145 |
|
case status::reset_content: return "Reset Content";
|
145 |
|
case status::reset_content: return "Reset Content";
|
| 146 |
|
case status::partial_content: return "Partial Content";
|
146 |
|
case status::partial_content: return "Partial Content";
|
| 147 |
|
case status::multi_status: return "Multi-Status";
|
147 |
|
case status::multi_status: return "Multi-Status";
|
| 148 |
|
case status::already_reported: return "Already Reported";
|
148 |
|
case status::already_reported: return "Already Reported";
|
| 149 |
|
case status::im_used: return "IM Used";
|
149 |
|
case status::im_used: return "IM Used";
|
| 150 |
|
|
150 |
|
|
| 151 |
|
|
151 |
|
|
| 152 |
|
case status::multiple_choices: return "Multiple Choices";
|
152 |
|
case status::multiple_choices: return "Multiple Choices";
|
| 153 |
|
case status::moved_permanently: return "Moved Permanently";
|
153 |
|
case status::moved_permanently: return "Moved Permanently";
|
| 154 |
|
case status::found: return "Found";
|
154 |
|
case status::found: return "Found";
|
| 155 |
|
case status::see_other: return "See Other";
|
155 |
|
case status::see_other: return "See Other";
|
| 156 |
|
case status::not_modified: return "Not Modified";
|
156 |
|
case status::not_modified: return "Not Modified";
|
| 157 |
|
case status::use_proxy: return "Use Proxy";
|
157 |
|
case status::use_proxy: return "Use Proxy";
|
| 158 |
|
case status::temporary_redirect: return "Temporary Redirect";
|
158 |
|
case status::temporary_redirect: return "Temporary Redirect";
|
| 159 |
|
case status::permanent_redirect: return "Permanent Redirect";
|
159 |
|
case status::permanent_redirect: return "Permanent Redirect";
|
| 160 |
|
|
160 |
|
|
| 161 |
|
|
161 |
|
|
| 162 |
|
case status::bad_request: return "Bad Request";
|
162 |
|
case status::bad_request: return "Bad Request";
|
| 163 |
|
case status::unauthorized: return "Unauthorized";
|
163 |
|
case status::unauthorized: return "Unauthorized";
|
| 164 |
|
case status::payment_required: return "Payment Required";
|
164 |
|
case status::payment_required: return "Payment Required";
|
| 165 |
|
case status::forbidden: return "Forbidden";
|
165 |
|
case status::forbidden: return "Forbidden";
|
| 166 |
|
case status::not_found: return "Not Found";
|
166 |
|
case status::not_found: return "Not Found";
|
| 167 |
|
case status::method_not_allowed: return "Method Not Allowed";
|
167 |
|
case status::method_not_allowed: return "Method Not Allowed";
|
| 168 |
|
case status::not_acceptable: return "Not Acceptable";
|
168 |
|
case status::not_acceptable: return "Not Acceptable";
|
| 169 |
|
case status::proxy_authentication_required: return "Proxy Authentication Required";
|
169 |
|
case status::proxy_authentication_required: return "Proxy Authentication Required";
|
| 170 |
|
case status::request_timeout: return "Request Timeout";
|
170 |
|
case status::request_timeout: return "Request Timeout";
|
| 171 |
|
case status::conflict: return "Conflict";
|
171 |
|
case status::conflict: return "Conflict";
|
| 172 |
|
case status::gone: return "Gone";
|
172 |
|
case status::gone: return "Gone";
|
| 173 |
|
case status::length_required: return "Length Required";
|
173 |
|
case status::length_required: return "Length Required";
|
| 174 |
|
case status::precondition_failed: return "Precondition Failed";
|
174 |
|
case status::precondition_failed: return "Precondition Failed";
|
| 175 |
|
case status::payload_too_large: return "Payload Too Large";
|
175 |
|
case status::payload_too_large: return "Payload Too Large";
|
| 176 |
|
case status::uri_too_long: return "URI Too Long";
|
176 |
|
case status::uri_too_long: return "URI Too Long";
|
| 177 |
|
case status::unsupported_media_type: return "Unsupported Media Type";
|
177 |
|
case status::unsupported_media_type: return "Unsupported Media Type";
|
| 178 |
|
case status::range_not_satisfiable: return "Range Not Satisfiable";
|
178 |
|
case status::range_not_satisfiable: return "Range Not Satisfiable";
|
| 179 |
|
case status::expectation_failed: return "Expectation Failed";
|
179 |
|
case status::expectation_failed: return "Expectation Failed";
|
| 180 |
|
case status::misdirected_request: return "Misdirected Request";
|
180 |
|
case status::misdirected_request: return "Misdirected Request";
|
| 181 |
|
case status::unprocessable_entity: return "Unprocessable Entity";
|
181 |
|
case status::unprocessable_entity: return "Unprocessable Entity";
|
| 182 |
|
case status::locked: return "Locked";
|
182 |
|
case status::locked: return "Locked";
|
| 183 |
|
case status::failed_dependency: return "Failed Dependency";
|
183 |
|
case status::failed_dependency: return "Failed Dependency";
|
| 184 |
|
case status::too_early: return "Too Early";
|
184 |
|
case status::too_early: return "Too Early";
|
| 185 |
|
case status::upgrade_required: return "Upgrade Required";
|
185 |
|
case status::upgrade_required: return "Upgrade Required";
|
| 186 |
|
case status::precondition_required: return "Precondition Required";
|
186 |
|
case status::precondition_required: return "Precondition Required";
|
| 187 |
|
case status::too_many_requests: return "Too Many Requests";
|
187 |
|
case status::too_many_requests: return "Too Many Requests";
|
| 188 |
|
case status::request_header_fields_too_large: return "Request Header Fields Too Large";
|
188 |
|
case status::request_header_fields_too_large: return "Request Header Fields Too Large";
|
| 189 |
|
case status::unavailable_for_legal_reasons: return "Unavailable For Legal Reasons";
|
189 |
|
case status::unavailable_for_legal_reasons: return "Unavailable For Legal Reasons";
|
| 190 |
|
|
190 |
|
|
| 191 |
|
|
191 |
|
|
| 192 |
|
case status::internal_server_error: return "Internal Server Error";
|
192 |
|
case status::internal_server_error: return "Internal Server Error";
|
| 193 |
|
case status::not_implemented: return "Not Implemented";
|
193 |
|
case status::not_implemented: return "Not Implemented";
|
| 194 |
|
case status::bad_gateway: return "Bad Gateway";
|
194 |
|
case status::bad_gateway: return "Bad Gateway";
|
| 195 |
|
case status::service_unavailable: return "Service Unavailable";
|
195 |
|
case status::service_unavailable: return "Service Unavailable";
|
| 196 |
|
case status::gateway_timeout: return "Gateway Timeout";
|
196 |
|
case status::gateway_timeout: return "Gateway Timeout";
|
| 197 |
|
case status::http_version_not_supported: return "HTTP Version Not Supported";
|
197 |
|
case status::http_version_not_supported: return "HTTP Version Not Supported";
|
| 198 |
|
case status::variant_also_negotiates: return "Variant Also Negotiates";
|
198 |
|
case status::variant_also_negotiates: return "Variant Also Negotiates";
|
| 199 |
|
case status::insufficient_storage: return "Insufficient Storage";
|
199 |
|
case status::insufficient_storage: return "Insufficient Storage";
|
| 200 |
|
case status::loop_detected: return "Loop Detected";
|
200 |
|
case status::loop_detected: return "Loop Detected";
|
| 201 |
|
case status::not_extended: return "Not Extended";
|
201 |
|
case status::not_extended: return "Not Extended";
|
| 202 |
|
case status::network_authentication_required: return "Network Authentication Required";
|
202 |
|
case status::network_authentication_required: return "Network Authentication Required";
|
| 203 |
|
|
203 |
|
|
| 204 |
|
|
204 |
|
|
| 205 |
|
|
205 |
|
|
| 206 |
|
|
206 |
|
|
| 207 |
|
return "<unknown-status>";
|
207 |
|
return "<unknown-status>";
|
| 208 |
|
|
208 |
|
|
| 209 |
|
|
209 |
|
|
| 210 |
|
|
210 |
|
|
| 211 |
|
operator<<(std::ostream& os, status v)
|
211 |
|
operator<<(std::ostream& os, status v)
|
| 212 |
|
|
212 |
|
|
| 213 |
|
return os << to_string(v);
|
213 |
|
return os << to_string(v);
|
| 214 |
|
|
214 |
|
|
| 215 |
|
|
215 |
|
|
| 216 |
|
|
216 |
|
|
| 217 |
|
|
217 |
|
|