28 #ifndef WEBSOCKETPP_PROCESSOR_HPP
29 #define WEBSOCKETPP_PROCESSOR_HPP
31 #include <websocketpp/processors/base.hpp>
32 #include <websocketpp/common/system_error.hpp>
34 #include <websocketpp/close.hpp>
35 #include <websocketpp/utilities.hpp>
36 #include <websocketpp/uri.hpp>
67 template <
typename request_type>
71 std::string
const & upgrade_header = r.get_header(
"Upgrade");
73 if (ci_find_substr(upgrade_header,
constants::upgrade_token,
74 sizeof(
constants::upgrade_token)-1) == upgrade_header.end())
79 std::string
const & con_header = r.get_header(
"Connection");
81 if (ci_find_substr(con_header,
constants::connection_token,
82 sizeof(
constants::connection_token)-1) == con_header.end())
106 template <
typename request_type>
112 if (r.get_header(
"Sec-WebSocket-Version").empty()) {
117 std::istringstream ss(r.get_header(
"Sec-WebSocket-Version"));
119 if ((ss >> version).fail()) {
135 template <
typename request_type>
137 std::string h = request.get_header(
"Host");
139 size_t last_colon = h.rfind(
":");
140 size_t last_sbrace = h.rfind(
"]");
146 if (last_colon == std::string::npos ||
147 (last_sbrace != std::string::npos && last_sbrace > last_colon))
149 return lib::make_shared<
uri>(scheme, h, request.get_uri());
151 return lib::make_shared<uri>(scheme,
152 h.substr(0,last_colon),
153 h.substr(last_colon+1),
159 template <
typename config>
163 typedef typename config::request_type request_type;
164 typedef typename config::response_type response_type;
165 typedef typename config::message_type::ptr message_ptr;
166 typedef std::pair<lib::error_code,std::string> err_str_pair;
168 explicit processor(
bool secure,
bool p_is_server)
170 , m_server(p_is_server)
171 , m_max_message_size(config::max_message_size)
174 virtual ~processor() {}
189 return m_max_message_size;
204 m_max_message_size = new_value;
226 return err_str_pair();
240 return err_str_pair();
265 std::string
const & subprotocol, response_type& res)
const = 0;
274 uri_ptr uri, std::vector<std::string>
const & subprotocols)
const = 0;
283 const & req, response_type & res)
const = 0;
286 virtual std::string
get_raw(response_type
const & request)
const = 0;
289 virtual std::string
const &
get_origin(request_type
const & request)
const = 0;
301 std::vector<std::string> & subprotocol_list) = 0;
369 virtual lib::error_code
prepare_ping(std::string
const & in, message_ptr out)
const
381 virtual lib::error_code
prepare_pong(std::string
const & in, message_ptr out)
const
397 std::string
const & reason, message_ptr out)
const = 0;
401 size_t m_max_message_size;