NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
websocketpp::close::status Namespace Reference

A package of types and methods for manipulating WebSocket close status'. More...

Typedefs

typedef uint16_t value
 The type of a close code value. More...
 

Functions

bool reserved (value code)
 Test whether a close code is in a reserved range. More...
 
bool invalid (value code)
 Test whether a close code is invalid on the wire. More...
 
bool terminal (value code)
 Determine if the code represents an unrecoverable error. More...
 
std::string get_string (value code)
 Return a human readable interpretation of a WebSocket close code. More...
 

Variables

static value const blank = 0
 A blank value for internal use. More...
 
static value const omit_handshake = 1
 Close the connection without a WebSocket close handshake. More...
 
static value const force_tcp_drop = 2
 Close the connection with a forced TCP drop. More...
 
static value const normal = 1000
 Normal closure, meaning that the purpose for which the connection was established has been fulfilled. More...
 
static value const going_away = 1001
 The endpoint was "going away", such as a server going down or a browser navigating away from a page. More...
 
static value const protocol_error = 1002
 A protocol error occurred. More...
 
static value const unsupported_data = 1003
 The connection was terminated because an endpoint received a type of data it cannot accept. More...
 
static value const no_status = 1005
 A dummy value to indicate that no status code was received. More...
 
static value const abnormal_close = 1006
 A dummy value to indicate that the connection was closed abnormally. More...
 
static value const invalid_payload = 1007
 An endpoint received message data inconsistent with its type. More...
 
static value const policy_violation = 1008
 An endpoint received a message that violated its policy. More...
 
static value const message_too_big = 1009
 An endpoint received a message too large to process. More...
 
static value const extension_required = 1010
 A client expected the server to accept a required extension request. More...
 
static value const internal_endpoint_error = 1011
 An endpoint encountered an unexpected condition that prevented it from fulfilling the request. More...
 
static value const service_restart = 1012
 Indicates that the service is restarted. More...
 
static value const try_again_later = 1013
 Indicates that the service is experiencing overload. More...
 
static value const bad_gateway = 1014
 Indicates that the server was acting as a gateway or proxy and received an invalid response from the upstream server. More...
 
static value const tls_handshake = 1015
 An endpoint failed to perform a TLS handshake. More...
 
static value const subprotocol_error = 3000
 A generic subprotocol error. More...
 
static value const invalid_subprotocol_data = 3001
 A invalid subprotocol data. More...
 
static value const rsv_start = 1016
 First value in range reserved for future protocol use. More...
 
static value const rsv_end = 2999
 Last value in range reserved for future protocol use. More...
 
static value const invalid_low = 999
 First value in range that is always invalid on the wire. More...
 
static value const invalid_high = 5000
 Last value in range that is always invalid on the wire. More...
 

Detailed Description

A package of types and methods for manipulating WebSocket close status'.

Typedef Documentation

◆ value

The type of a close code value.

Definition at line 49 of file close.hpp.

Function Documentation

◆ reserved()

bool websocketpp::close::status::reserved ( value  code)
inline

Test whether a close code is in a reserved range.

Parameters
[in]codeThe code to test
Returns
Whether or not code is reserved

Definition at line 184 of file close.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), websocketpp::close::extract_code(), and websocketpp::processor::hybi13< stub_config >::prepare_close().

◆ invalid()

bool websocketpp::close::status::invalid ( value  code)
inline

Test whether a close code is invalid on the wire.

Parameters
[in]codeThe code to test
Returns
Whether or not code is invalid on the wire

Definition at line 199 of file close.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), websocketpp::close::extract_code(), and websocketpp::processor::hybi13< stub_config >::prepare_close().

◆ terminal()

bool websocketpp::close::status::terminal ( value  code)
inline

Determine if the code represents an unrecoverable error.

There is a class of errors for which once they are discovered normal WebSocket functionality can no longer occur. This function determines if a given code is one of these values. This information is used to determine if the system has the capability of waiting for a close acknowledgement or if it should drop the TCP connection immediately after sending its close frame.

Parameters
[in]codeThe value to test.
Returns
True if the code represents an unrecoverable error

Definition at line 217 of file close.hpp.

Referenced by websocketpp::connection< stub_config >::close(), websocketpp::connection< stub_config >::get_supported_versions(), websocketpp::connection< stub_config >::handle_write_frame(), and websocketpp::connection< stub_config >::set_handle().

◆ get_string()

std::string websocketpp::close::status::get_string ( value  code)
inline

Return a human readable interpretation of a WebSocket close code.

See https://tools.ietf.org/html/rfc6455#section-7.4 for more details.

Since
0.3.0
Parameters
[in]codeThe code to look up.
Returns
A human readable interpretation of the code.

Definition at line 232 of file close.hpp.

References abnormal_close, bad_gateway, extension_required, going_away, internal_endpoint_error, invalid_payload, invalid_subprotocol_data, message_too_big, no_status, normal, policy_violation, protocol_error, service_restart, subprotocol_error, tls_handshake, try_again_later, and unsupported_data.

Referenced by http_func(), connection_metadata::on_close(), and websocketpp::http::parser::response::set_status().

Variable Documentation

◆ blank

value const websocketpp::close::status::blank = 0
static

◆ omit_handshake

value const websocketpp::close::status::omit_handshake = 1
static

Close the connection without a WebSocket close handshake.

This special value requests that the WebSocket connection be closed without performing the WebSocket closing handshake. This does not comply with RFC6455, but should be safe to do if necessary. This could be useful for clients that need to disconnect quickly and cannot afford the complete handshake.

Definition at line 62 of file close.hpp.

◆ force_tcp_drop

value const websocketpp::close::status::force_tcp_drop = 2
static

Close the connection with a forced TCP drop.

This special value requests that the WebSocket connection be closed by forcibly dropping the TCP connection. This will leave the other side of the connection with a broken connection and some expensive timeouts. this should not be done except in extreme cases or in cases of malicious remote endpoints.

Definition at line 72 of file close.hpp.

◆ normal

value const websocketpp::close::status::normal = 1000
static

Normal closure, meaning that the purpose for which the connection was established has been fulfilled.

Definition at line 76 of file close.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), close(), close_after_timeout(), nfd::face::WebSocketTransport::doClose(), get_string(), websocketpp::connection< stub_config >::get_supported_versions(), main(), and req_pong_timeout().

◆ going_away

value const websocketpp::close::status::going_away = 1001
static

The endpoint was "going away", such as a server going down or a browser navigating away from a page.

Definition at line 80 of file close.hpp.

Referenced by get_string(), perftest::on_message(), and websocket_endpoint::~websocket_endpoint().

◆ protocol_error

value const websocketpp::close::status::protocol_error = 1002
static

◆ unsupported_data

value const websocketpp::close::status::unsupported_data = 1003
static

The connection was terminated because an endpoint received a type of data it cannot accept.

(e.g., an endpoint that understands only text data MAY send this if it receives a binary message).

Definition at line 91 of file close.hpp.

Referenced by get_string().

◆ no_status

value const websocketpp::close::status::no_status = 1005
static

A dummy value to indicate that no status code was received.

This value is illegal on the wire.

Definition at line 97 of file close.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), websocketpp::close::extract_code(), get_string(), websocketpp::connection< stub_config >::get_supported_versions(), and websocketpp::processor::hybi13< stub_config >::prepare_close().

◆ abnormal_close

value const websocketpp::close::status::abnormal_close = 1006
static

A dummy value to indicate that the connection was closed abnormally.

In such a case there was no close frame to extract a value from. This value is illegal on the wire.

Definition at line 104 of file close.hpp.

Referenced by get_string(), and websocketpp::connection< stub_config >::terminate().

◆ invalid_payload

value const websocketpp::close::status::invalid_payload = 1007
static

An endpoint received message data inconsistent with its type.

For example: Invalid UTF8 bytes in a text message.

Definition at line 110 of file close.hpp.

Referenced by get_string(), and websocketpp::processor::error::to_ws().

◆ policy_violation

value const websocketpp::close::status::policy_violation = 1008
static

An endpoint received a message that violated its policy.

This is a generic status code that can be returned when there is no other more suitable status code (e.g., 1003 or 1009) or if there is a need to hide specific details about the policy.

Definition at line 118 of file close.hpp.

Referenced by get_string().

◆ message_too_big

value const websocketpp::close::status::message_too_big = 1009
static

An endpoint received a message too large to process.

Definition at line 121 of file close.hpp.

Referenced by get_string(), and websocketpp::processor::error::to_ws().

◆ extension_required

value const websocketpp::close::status::extension_required = 1010
static

A client expected the server to accept a required extension request.

The list of extensions that are needed SHOULD appear in the /reason/ part of the Close frame. Note that this status code is not used by the server, because it can fail the WebSocket handshake instead.

Definition at line 129 of file close.hpp.

Referenced by get_string().

◆ internal_endpoint_error

value const websocketpp::close::status::internal_endpoint_error = 1011
static

An endpoint encountered an unexpected condition that prevented it from fulfilling the request.

Definition at line 133 of file close.hpp.

Referenced by get_string(), and websocketpp::processor::error::to_ws().

◆ service_restart

value const websocketpp::close::status::service_restart = 1012
static

Indicates that the service is restarted.

A client may reconnect and if if it chooses to do so, should reconnect using a randomized delay of 5-30s

Definition at line 138 of file close.hpp.

Referenced by get_string().

◆ try_again_later

value const websocketpp::close::status::try_again_later = 1013
static

Indicates that the service is experiencing overload.

A client should only connect to a different IP (when there are multiple for the target) or reconnect to the same IP upon user action.

Definition at line 143 of file close.hpp.

Referenced by get_string().

◆ bad_gateway

value const websocketpp::close::status::bad_gateway = 1014
static

Indicates that the server was acting as a gateway or proxy and received an invalid response from the upstream server.

This is similar to 502 HTTP Status Code.

Definition at line 148 of file close.hpp.

Referenced by get_string().

◆ tls_handshake

value const websocketpp::close::status::tls_handshake = 1015
static

An endpoint failed to perform a TLS handshake.

Designated for use in applications expecting a status code to indicate that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified). This value is illegal on the wire.

Definition at line 157 of file close.hpp.

Referenced by get_string().

◆ subprotocol_error

value const websocketpp::close::status::subprotocol_error = 3000
static

A generic subprotocol error.

Indicates that a subprotocol error occurred. Typically this involves receiving a message that is not formatted as a valid message for the subprotocol in use.

Definition at line 165 of file close.hpp.

Referenced by get_string().

◆ invalid_subprotocol_data

value const websocketpp::close::status::invalid_subprotocol_data = 3001
static

A invalid subprotocol data.

Indicates that data was received that violated the specification of the subprotocol in use.

Definition at line 172 of file close.hpp.

Referenced by get_string().

◆ rsv_start

value const websocketpp::close::status::rsv_start = 1016
static

First value in range reserved for future protocol use.

Definition at line 175 of file close.hpp.

◆ rsv_end

value const websocketpp::close::status::rsv_end = 2999
static

Last value in range reserved for future protocol use.

Definition at line 177 of file close.hpp.

◆ invalid_low

value const websocketpp::close::status::invalid_low = 999
static

First value in range that is always invalid on the wire.

Definition at line 190 of file close.hpp.

◆ invalid_high

value const websocketpp::close::status::invalid_high = 5000
static

Last value in range that is always invalid on the wire.

Definition at line 192 of file close.hpp.