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

Processors encapsulate the protocol rules specific to each WebSocket version. More...

Namespaces

 constants
 Constants related to processing WebSocket connections.
 
 error
 Error code category and codes used by all processor types.
 
 error_cat
 Processor class related error codes.
 

Classes

class  hybi00
 Processor for Hybi Draft version 00. More...
 
class  hybi07
 Processor for Hybi Draft version 07. More...
 
class  hybi08
 Processor for Hybi Draft version 08. More...
 
class  hybi13
 Processor for Hybi version 13 (RFC6455) More...
 
class  processor
 WebSocket protocol processor abstract base class. More...
 

Functions

template<typename request_type >
bool is_websocket_handshake (request_type &r)
 Determine whether or not a generic HTTP request is a WebSocket handshake. More...
 
template<typename request_type >
int get_websocket_version (request_type &r)
 Extract the version from a WebSocket handshake request. More...
 
template<typename request_type >
uri_ptr get_uri_from_host (request_type &request, std::string scheme)
 Extract a URI ptr from the host header of the request. More...
 

Detailed Description

Processors encapsulate the protocol rules specific to each WebSocket version.

The processors namespace includes a number of free functions that operate on various WebSocket related data structures and perform processing that is not related to specific versions of the protocol.

It also includes the abstract interface for the protocol specific processing engines. These engines wrap all of the logic necessary for parsing and validating WebSocket handshakes and messages of specific protocol version and set of allowed extensions.

An instance of a processor represents the state of a single WebSocket connection of the associated version. One processor instance is needed per logical WebSocket connection.

Function Documentation

template<typename request_type >
bool websocketpp::processor::is_websocket_handshake ( request_type &  r)

Determine whether or not a generic HTTP request is a WebSocket handshake.

Parameters
rThe HTTP request to read.
Returns
True if the request is a WebSocket handshake, false otherwise

Definition at line 68 of file processor.hpp.

References websocketpp::utility::ci_find_substr(), websocketpp::processor::constants::connection_token, and websocketpp::processor::constants::upgrade_token.

Referenced by BOOST_AUTO_TEST_CASE(), websocketpp::connection< config >::get_supported_versions(), websocketpp::connection< config >::initialize_processor(), and websocketpp::connection< config >::process_handshake_request().

template<typename request_type >
int websocketpp::processor::get_websocket_version ( request_type &  r)

Extract the version from a WebSocket handshake request.

A blank version header indicates a spec before versions were introduced. The only such versions in shipping products are Hixie Draft 75 and Hixie Draft 76. Draft 75 is present in Chrome 4-5 and Safari 5.0.0, Draft 76 (also known as hybi 00 is present in Chrome 6-13 and Safari 5.0.1+. As differentiating between these two sets of browsers is very difficult and Safari 5.0.1+ accounts for the vast majority of cases in the wild this function assumes that all handshakes without a valid version header are Hybi 00.

Parameters
rThe WebSocket handshake request to read.
Returns
The WebSocket handshake version or -1 if there was an extraction error.

Definition at line 107 of file processor.hpp.

References websocketpp::http::parser::state::version.

Referenced by BOOST_AUTO_TEST_CASE(), websocketpp::connection< config >::get_supported_versions(), and websocketpp::connection< config >::initialize_processor().

template<typename request_type >
uri_ptr websocketpp::processor::get_uri_from_host ( request_type &  request,
std::string  scheme 
)

Extract a URI ptr from the host header of the request.

Parameters
requestThe request to extract the Host header from.
schemeThe scheme under which this request was received (ws, wss, http, https, etc)
Returns
A uri_pointer that encodes the value of the host header.

Definition at line 136 of file processor.hpp.

Referenced by websocketpp::processor::hybi13< stub_config >::get_uri(), and websocketpp::connection< config >::process_handshake_request().