WebSocket++
0.8.2
C++ websocket client/server library
|
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,
163 processor_category() {}
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";
245 return lib::error_code(
static_cast<
int>(e), get_processor_category());
262 if (ec.category() != get_processor_category()) {
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;
295 static bool const value =
true;
@ non_minimal_encoding
Payload length not minimally encoded.
static value const blank
A blank value for internal use.
Error code category and codes used by all processor types.
@ reason_requires_code
Using a reason requires a close code.
@ invalid_rsv_bit
Illegal use of reserved bit.
@ no_protocol_support
No support for this feature in this protocol version.
#define _WEBSOCKETPP_NOEXCEPT_TOKEN_
Category for processor errors.
uint16_t value
The type of a close code value.
@ extensions_disabled
Extension related operation was ignored because extensions are disabled.
@ not_implemented
Operation required not implemented functionality.
@ invalid_payload
Processor encountered invalid payload data.
lib::error_category const & get_processor_category()
Get a reference to a static copy of the processor error category.
Constants related to processing WebSocket connections.
static std::vector< int > const versions_supported(helper, helper+4)
Container that stores the list of protocol versions supported.
@ bad_request
Error was the result of improperly formatted user input.
@ invalid_http_version
Invalid HTTP version.
@ protocol_violation
Processor encountered a protocol violation in an incoming message.
@ invalid_http_status
Invalid HTTP status.
A package of types and methods for manipulating WebSocket close codes.
lib::error_code make_error_code(error::processor_errors e)
Create an error code with the given value and the processor category.
@ missing_required_header
Missing Required Header.
close::status::value to_ws(lib::error_code ec)
Converts a processor error_code into a websocket close code.
@ invalid_http_method
Invalid HTTP method.
@ invalid_continuation
Continuation without message.
@ requires_64bit
Not supported on 32 bit systems.
@ fragmented_control
Fragmented control message.
Processor class related error codes.
@ masking_forbidden
Servers may not send masked frames.
A package of types and methods for manipulating WebSocket close status'.
Processors encapsulate the protocol rules specific to each WebSocket version.
@ subprotocol_parse_error
Error parsing subprotocols.
@ reserved_close_code
Reserved close code used.
@ message_too_big
Processor encountered a message that was too large.
@ invalid_close_code
Invalid close code used.
@ control_too_big
Control frame too large.
#define _WEBSOCKETPP_ERROR_CODE_ENUM_NS_END_
@ extension_parse_error
Error parsing extensions.
@ invalid_arguments
The processor method was called with invalid arguments.
#define _WEBSOCKETPP_ERROR_CODE_ENUM_NS_START_
@ invalid_utf8
Invalid UTF-8 encoding.
@ sha1_library
Embedded SHA-1 library error.
@ masking_required
Clients may not send unmasked frames.
@ invalid_opcode
Opcode was invalid for requested operation.