28 #ifndef WEBSOCKETPP_PROCESSOR_BASE_HPP
29 #define WEBSOCKETPP_PROCESSOR_BASE_HPP
31 #include <websocketpp/close.hpp>
32 #include <websocketpp/utilities.hpp>
33 #include <websocketpp/uri.hpp>
35 #include <websocketpp/common/cpp11.hpp>
36 #include <websocketpp/common/system_error.hpp>
46 static char const upgrade_token[] =
"websocket";
47 static char const connection_token[] =
"Upgrade";
48 static char const handshake_guid[] =
"258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
58 PROTOCOL_VIOLATION = 2,
161 class processor_category :
public lib::error_category {
163 processor_category() {}
165 char const * name()
const _WEBSOCKETPP_NOEXCEPT_TOKEN_ {
166 return "websocketpp.processor";
169 std::string message(
int value)
const {
172 return "Generic processor error";
173 case error::bad_request:
174 return "invalid user input";
175 case error::protocol_violation:
176 return "Generic protocol violation";
177 case error::message_too_big:
178 return "A message was too large";
179 case error::invalid_payload:
180 return "A payload contained invalid data";
181 case error::invalid_arguments:
182 return "invalid function arguments";
183 case error::invalid_opcode:
184 return "invalid opcode";
185 case error::control_too_big:
186 return "Control messages are limited to fewer than 125 characters";
187 case error::invalid_rsv_bit:
188 return "Invalid use of reserved bits";
189 case error::fragmented_control:
190 return "Control messages cannot be fragmented";
191 case error::invalid_continuation:
192 return "Invalid message continuation";
193 case error::masking_required:
194 return "Clients may not send unmasked frames";
195 case error::masking_forbidden:
196 return "Servers may not send masked frames";
197 case error::non_minimal_encoding:
198 return "Payload length was not minimally encoded";
199 case error::requires_64bit:
200 return "64 bit frames are not supported on 32 bit systems";
201 case error::invalid_utf8:
202 return "Invalid UTF8 encoding";
203 case error::not_implemented:
204 return "Operation required not implemented functionality";
205 case error::invalid_http_method:
206 return "Invalid HTTP method.";
207 case error::invalid_http_version:
208 return "Invalid HTTP version.";
209 case error::invalid_http_status:
210 return "Invalid HTTP status.";
211 case error::missing_required_header:
212 return "A required HTTP header is missing";
213 case error::sha1_library:
214 return "SHA-1 library error";
215 case error::no_protocol_support:
216 return "The WebSocket protocol version in use does not support this feature";
217 case error::reserved_close_code:
218 return "Reserved close code used";
219 case error::invalid_close_code:
220 return "Invalid close code used";
221 case error::reason_requires_code:
222 return "Using a close reason requires a valid close code";
223 case error::subprotocol_parse_error:
224 return "Error parsing subprotocol header";
225 case error::extension_parse_error:
226 return "Error parsing extension header";
227 case error::extensions_disabled:
228 return "Extensions are disabled";
229 case error::short_key3:
230 return "Short Hybi00 Key 3 read";
239 static processor_category instance;
245 return lib::error_code(
static_cast<
int>(e), get_processor_category());
262 if (ec.category() != get_processor_category()) {
263 return close::status::blank;
266 switch (ec.value()) {
267 case error::protocol_violation:
268 case error::control_too_big:
269 case error::invalid_opcode:
270 case error::invalid_rsv_bit:
271 case error::fragmented_control:
272 case error::invalid_continuation:
273 case error::masking_required:
274 case error::masking_forbidden:
275 case error::reserved_close_code:
276 case error::invalid_close_code:
277 return close::status::protocol_error;
278 case error::invalid_payload:
279 case error::invalid_utf8:
280 return close::status::invalid_payload;
281 case error::message_too_big:
282 return close::status::message_too_big;
284 return close::status::internal_endpoint_error;
292 _WEBSOCKETPP_ERROR_CODE_ENUM_NS_START_
293 template<>
struct is_error_code_enum<websocketpp::processor::error::processor_errors>
295 static bool const value =
true;
297 _WEBSOCKETPP_ERROR_CODE_ENUM_NS_END_