Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:35

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_WEBSOCKET_ERROR_HPP
0011 #define BOOST_BEAST_WEBSOCKET_ERROR_HPP
0012 
0013 #include <boost/beast/core/detail/config.hpp>
0014 #include <boost/beast/core/error.hpp>
0015 
0016 namespace boost {
0017 namespace beast {
0018 namespace websocket {
0019 
0020 /// Error codes returned from @ref boost::beast::websocket::stream operations.
0021 enum class error
0022 {
0023     /** The WebSocket stream was gracefully closed at both endpoints
0024     */
0025     closed = 1,
0026 
0027 /*  The error codes error::failed and error::handshake_failed
0028     are no longer in use. Please change your code to compare values
0029     of type error_code against condition::handshake_failed
0030     and condition::protocol_violation instead.
0031             
0032     Apologies for the inconvenience.
0033 
0034     - VFALCO
0035 */
0036 #if ! BOOST_BEAST_DOXYGEN
0037     unused1 = 2, // failed
0038     unused2 = 3, // handshake_failed
0039 #endif
0040 
0041     /** The WebSocket operation caused a dynamic buffer overflow
0042     */
0043     buffer_overflow,
0044 
0045     /** The WebSocket stream produced an incomplete deflate block
0046     */
0047     partial_deflate_block,
0048 
0049     /** The WebSocket message  exceeded the locally configured limit
0050     */
0051     message_too_big,
0052 
0053     //
0054     // Handshake failure errors
0055     //
0056     // These will compare equal to condition::handshake_failed
0057     //
0058 
0059     /** The WebSocket handshake was not HTTP/1.1
0060 
0061         Error codes with this value will compare equal to @ref condition::handshake_failed
0062     */
0063     bad_http_version,
0064 
0065     /** The WebSocket handshake method was not GET
0066 
0067         Error codes with this value will compare equal to @ref condition::handshake_failed
0068     */
0069     bad_method,
0070 
0071     /** The WebSocket handshake Host field is missing
0072 
0073         Error codes with this value will compare equal to @ref condition::handshake_failed
0074     */
0075     no_host,
0076 
0077     /** The WebSocket handshake Connection field is missing
0078 
0079         Error codes with this value will compare equal to @ref condition::handshake_failed
0080     */
0081     no_connection,
0082 
0083     /** The WebSocket handshake Connection field is missing the upgrade token
0084 
0085         Error codes with this value will compare equal to @ref condition::handshake_failed
0086     */
0087     no_connection_upgrade,
0088 
0089     /** The WebSocket handshake Upgrade field is missing
0090 
0091         Error codes with this value will compare equal to @ref condition::handshake_failed
0092     */
0093     no_upgrade,
0094 
0095     /** The WebSocket handshake Upgrade field is missing the websocket token
0096 
0097         Error codes with this value will compare equal to @ref condition::handshake_failed
0098     */
0099     no_upgrade_websocket,
0100 
0101     /** The WebSocket handshake Sec-WebSocket-Key field is missing
0102 
0103         Error codes with this value will compare equal to @ref condition::handshake_failed
0104     */
0105     no_sec_key,
0106 
0107     /** The WebSocket handshake Sec-WebSocket-Key field is invalid
0108 
0109         Error codes with this value will compare equal to @ref condition::handshake_failed
0110     */
0111     bad_sec_key,
0112 
0113     /** The WebSocket handshake Sec-WebSocket-Version field is missing
0114 
0115         Error codes with this value will compare equal to @ref condition::handshake_failed
0116     */
0117     no_sec_version,
0118 
0119     /** The WebSocket handshake Sec-WebSocket-Version field is invalid
0120 
0121         Error codes with this value will compare equal to @ref condition::handshake_failed
0122     */
0123     bad_sec_version,
0124 
0125     /** The WebSocket handshake Sec-WebSocket-Accept field is missing
0126 
0127         Error codes with this value will compare equal to @ref condition::handshake_failed
0128     */
0129     no_sec_accept,
0130 
0131     /** The WebSocket handshake Sec-WebSocket-Accept field is invalid
0132 
0133         Error codes with this value will compare equal to @ref condition::handshake_failed
0134     */
0135     bad_sec_accept,
0136 
0137     /** The WebSocket handshake was declined by the remote peer
0138 
0139         Error codes with this value will compare equal to @ref condition::handshake_failed
0140     */
0141     upgrade_declined,
0142 
0143     //
0144     // Protocol errors
0145     //
0146     // These will compare equal to condition::protocol_violation
0147     //
0148 
0149     /** The WebSocket frame contained an illegal opcode
0150 
0151         Error codes with this value will compare equal to @ref condition::protocol_violation
0152     */
0153     bad_opcode,
0154 
0155     /** The WebSocket data frame was unexpected
0156 
0157         Error codes with this value will compare equal to @ref condition::protocol_violation
0158     */
0159     bad_data_frame,
0160 
0161     /** The WebSocket continuation frame was unexpected
0162 
0163         Error codes with this value will compare equal to @ref condition::protocol_violation
0164     */
0165     bad_continuation,
0166 
0167     /** The WebSocket frame contained illegal reserved bits
0168 
0169         Error codes with this value will compare equal to @ref condition::protocol_violation
0170     */
0171     bad_reserved_bits,
0172 
0173     /** The WebSocket control frame was fragmented
0174 
0175         Error codes with this value will compare equal to @ref condition::protocol_violation
0176     */
0177     bad_control_fragment,
0178 
0179     /** The WebSocket control frame size was invalid
0180 
0181         Error codes with this value will compare equal to @ref condition::protocol_violation
0182     */
0183     bad_control_size,
0184 
0185     /** The WebSocket frame was unmasked
0186 
0187         Error codes with this value will compare equal to @ref condition::protocol_violation
0188     */
0189     bad_unmasked_frame,
0190 
0191     /** The WebSocket frame was masked
0192 
0193         Error codes with this value will compare equal to @ref condition::protocol_violation
0194     */
0195     bad_masked_frame,
0196 
0197     /** The WebSocket frame size was not canonical
0198 
0199         Error codes with this value will compare equal to @ref condition::protocol_violation
0200     */
0201     bad_size,
0202 
0203     /** The WebSocket frame payload was not valid utf8
0204 
0205         Error codes with this value will compare equal to @ref condition::protocol_violation
0206     */
0207     bad_frame_payload,
0208 
0209     /** The WebSocket close frame reason code was invalid
0210 
0211         Error codes with this value will compare equal to @ref condition::protocol_violation
0212     */
0213     bad_close_code,
0214 
0215     /** The WebSocket close frame payload size was invalid
0216 
0217         Error codes with this value will compare equal to @ref condition::protocol_violation
0218     */
0219     bad_close_size,
0220 
0221     /** The WebSocket close frame payload was not valid utf8
0222 
0223         Error codes with this value will compare equal to @ref condition::protocol_violation
0224     */
0225     bad_close_payload
0226 };
0227 
0228 /// Error conditions corresponding to sets of error codes.
0229 enum class condition
0230 {
0231     /** The WebSocket handshake failed
0232 
0233         This condition indicates that the WebSocket handshake failed. If
0234         the corresponding HTTP response indicates the keep-alive behavior,
0235         then the handshake may be reattempted.
0236     */
0237     handshake_failed = 1,
0238 
0239     /** A WebSocket protocol violation occurred
0240 
0241         This condition indicates that the remote peer on the WebSocket
0242         connection sent data which violated the protocol.
0243     */
0244     protocol_violation
0245  };
0246 
0247 } // websocket
0248 } // beast
0249 } // boost
0250 
0251 #include <boost/beast/websocket/impl/error.hpp>
0252 #ifdef BOOST_BEAST_HEADER_ONLY
0253 #include <boost/beast/websocket/impl/error.ipp>
0254 #endif
0255 
0256 #endif