diff --git a/websocketpp/processors/base.hpp b/websocketpp/processors/base.hpp index 05946deb0e..79cbf84223 100644 --- a/websocketpp/processors/base.hpp +++ b/websocketpp/processors/base.hpp @@ -229,7 +229,7 @@ public: } }; -/// Get a reference to a static copy of the processor category +/// Get a reference to a static copy of the processor error category inline lib::error_category const & get_processor_category() { static processor_category instance; return instance; diff --git a/websocketpp/processors/hybi00.hpp b/websocketpp/processors/hybi00.hpp index 2b678438a7..9963f26f30 100644 --- a/websocketpp/processors/hybi00.hpp +++ b/websocketpp/processors/hybi00.hpp @@ -30,20 +30,13 @@ #include -// For htonl -#if defined(WIN32) - #include -#else - #include -#endif - -#include - #include #include - +#include #include +#include + namespace websocketpp { namespace processor { @@ -75,7 +68,7 @@ public: return 0; } - lib::error_code validate_handshake(const request_type& r) const { + lib::error_code validate_handshake(request_type const & r) const { if (r.get_method() != "GET") { return make_error_code(error::invalid_http_method); } @@ -98,8 +91,8 @@ public: return lib::error_code(); } - lib::error_code process_handshake(const request_type& req, const - std::string & subprotocol, response_type& res) const + lib::error_code process_handshake(request_type const & req, + std::string const & subprotocol, response_type & res) const { char key_final[16]; @@ -148,36 +141,36 @@ public: } // outgoing client connection processing is not supported for this version - lib::error_code client_handshake_request(request_type& req, uri_ptr uri, - const std::vector & subprotocols) const + lib::error_code client_handshake_request(request_type& req, uri_ptr uri, + std::vector const & subprotocols) const { return error::make_error_code(error::no_protocol_support); } - lib::error_code validate_server_handshake_response(const request_type& req, - response_type& res) const + lib::error_code validate_server_handshake_response(request_type const & req, + response_type & res) const { return error::make_error_code(error::no_protocol_support); } - std::string get_raw(const response_type& res) const { + std::string get_raw(response_type const & res) const { response_type temp = res; temp.remove_header("Sec-WebSocket-Key3"); return temp.raw() + res.get_header("Sec-WebSocket-Key3"); } - const std::string& get_origin(const request_type& r) const { + std::string const & get_origin(request_type const & r) const { return r.get_header("Origin"); } // hybi00 doesn't support subprotocols so there never will be any requested - lib::error_code extract_subprotocols(const request_type & req, + lib::error_code extract_subprotocols(request_type const & req, std::vector & subprotocol_list) { return lib::error_code(); } - uri_ptr get_uri(const request_type& request) const { + uri_ptr get_uri(request_type const & request) const { std::string h = request.get_header("Host"); size_t last_colon = h.rfind(":"); @@ -202,6 +195,11 @@ public: // TODO: check if get_uri is a full uri } + /// Get hybi00 handshake key3 + /** + * @todo This doesn't appear to be used anymore. It might be able to be + * removed + */ std::string get_key3() const { return ""; } @@ -306,11 +304,11 @@ public: } // generate header - out->set_header(std::string(reinterpret_cast(&msg_hdr),1)); + out->set_header(std::string(reinterpret_cast(&msg_hdr),1)); // process payload out->set_payload(i); - out->append_payload(std::string(reinterpret_cast(&msg_ftr),1)); + out->append_payload(std::string(reinterpret_cast(&msg_ftr),1)); // hybi00 doesn't support compression // hybi00 doesn't have masking @@ -320,7 +318,7 @@ public: return lib::error_code(); } - lib::error_code prepare_ping(const std::string & in, message_ptr out) const + lib::error_code prepare_ping(std::string const & in, message_ptr out) const { return lib::error_code(error::no_protocol_support); } @@ -330,8 +328,8 @@ public: return lib::error_code(error::no_protocol_support); } - lib::error_code prepare_close(close::status::value code, - const std::string & reason, message_ptr out) const + lib::error_code prepare_close(close::status::value code, + std::string const & reason, message_ptr out) const { if (!out) { return lib::error_code(error::invalid_arguments); @@ -346,7 +344,7 @@ public: return lib::error_code(); } private: - void decode_client_key(const std::string& key, char* result) const { + void decode_client_key(std::string const & key, char * result) const { unsigned int spaces = 0; std::string digits = ""; uint32_t num; @@ -378,8 +376,8 @@ private: FATAL_ERROR = 3 }; - const uint8_t msg_hdr; - const uint8_t msg_ftr; + uint8_t const msg_hdr; + uint8_t const msg_ftr; state m_state; @@ -388,7 +386,6 @@ private: utf8_validator::validator m_validator; }; - } // namespace processor } // namespace websocketpp diff --git a/websocketpp/processors/hybi07.hpp b/websocketpp/processors/hybi07.hpp index ade9777427..e1502cc318 100644 --- a/websocketpp/processors/hybi07.hpp +++ b/websocketpp/processors/hybi07.hpp @@ -41,28 +41,27 @@ template class hybi07 : public hybi08 { public: typedef typename config::request_type request_type; - + typedef typename config::con_msg_manager_type::ptr msg_manager_ptr; typedef typename config::rng_type rng_type; - - explicit hybi07(bool secure,bool server, msg_manager_ptr manager, - rng_type& rng) - : hybi08(secure, server, manager, rng) {} - + + explicit hybi07(bool secure, bool server, msg_manager_ptr manager, + rng_type& rng) + : hybi08(secure, server, manager, rng) {} + // outgoing client connection processing is not supported for this version - lib::error_code client_handshake_request(request_type& req, uri_ptr uri, - const std::vector & subprotocols) const + lib::error_code client_handshake_request(request_type & req, uri_ptr uri, + std::vector const & subprotocols) const { return error::make_error_code(error::no_protocol_support); } - + int get_version() const { return 7; } private: }; - } // namespace processor } // namespace websocketpp diff --git a/websocketpp/processors/hybi08.hpp b/websocketpp/processors/hybi08.hpp index 370b0c68f3..5463221918 100644 --- a/websocketpp/processors/hybi08.hpp +++ b/websocketpp/processors/hybi08.hpp @@ -51,8 +51,8 @@ public: : hybi13(secure, server, manager, rng) {} // outgoing client connection processing is not supported for this version - lib::error_code client_handshake_request(request_type& req, uri_ptr uri, - const std::vector & subprotocols) const + lib::error_code client_handshake_request(request_type& req, uri_ptr uri, + std::vector const & subprotocols) const { return error::make_error_code(error::no_protocol_support); } @@ -61,13 +61,12 @@ public: return 8; } - const std::string& get_origin(const request_type& r) const { + const std::string& get_origin(request_type const & r) const { return r.get_header("Sec-WebSocket-Origin"); } private: }; - } // namespace processor } // namespace websocketpp diff --git a/websocketpp/processors/hybi13.hpp b/websocketpp/processors/hybi13.hpp index 50560d4328..b97955ac92 100644 --- a/websocketpp/processors/hybi13.hpp +++ b/websocketpp/processors/hybi13.hpp @@ -28,18 +28,11 @@ #ifndef WEBSOCKETPP_PROCESSOR_HYBI13_HPP #define WEBSOCKETPP_PROCESSOR_HYBI13_HPP -// For htonl -#if defined(WIN32) - #include -#else - #include -#endif - #include #include #include - +#include #include #include diff --git a/websocketpp/processors/processor.hpp b/websocketpp/processors/processor.hpp index e5cc97262b..b8472ec148 100644 --- a/websocketpp/processors/processor.hpp +++ b/websocketpp/processors/processor.hpp @@ -165,8 +165,7 @@ public: virtual ~processor() {} - /// Returns the version of the WebSocket protocol that this processor - /// understands. + /// Get the protocol version of this processor virtual int get_version() const = 0; /// Returns whether or not the permessage_compress extension is implemented diff --git a/websocketpp/transport/asio/base.hpp b/websocketpp/transport/asio/base.hpp index 083d92b94a..a63d5ab835 100644 --- a/websocketpp/transport/asio/base.hpp +++ b/websocketpp/transport/asio/base.hpp @@ -39,39 +39,36 @@ namespace websocketpp { namespace transport { /// Transport policy that uses boost::asio -namespace asio { - -typedef lib::function - socket_shutdown_handler; - /** * This policy uses a single boost::asio io_service to provide transport - * services to a WebSocket++ endpoint. - * - * - * - * + * services to a WebSocket++ endpoint. */ +namespace asio { +typedef lib::function + socket_shutdown_handler; + +/// Asio transport errors namespace error { enum value { /// Catch-all error for transport policy errors that don't fit in other /// categories general = 1, - + /// async_read_at_least call requested more bytes than buffer can store invalid_num_bytes, - + /// there was an error in the underlying transport library pass_through, - + /// The connection to the requested proxy server failed proxy_failed, - + /// Invalid Proxy URI proxy_invalid }; +/// Asio transport error category class category : public lib::error_category { public: char const * name() const _WEBSOCKETPP_NOEXCEPT_TOKEN_ { @@ -96,11 +93,13 @@ public: } }; -inline const lib::error_category& get_category() { +/// Get a reference to a static copy of the asio transport error category +inline lib::error_category const & get_category() { static category instance; return instance; } +/// Create an error code with the given value and the asio transport category inline lib::error_code make_error_code(error::value e) { return lib::error_code(static_cast(e), get_category()); } diff --git a/websocketpp/transport/asio/connection.hpp b/websocketpp/transport/asio/connection.hpp index 0dd85db291..b7ed706a5b 100644 --- a/websocketpp/transport/asio/connection.hpp +++ b/websocketpp/transport/asio/connection.hpp @@ -771,7 +771,7 @@ protected: * * Might need a strand at some point? */ - lib::error_code interrupt(inturrupt_handler handler) { + lib::error_code interrupt(interrupt_handler handler) { m_io_service->post(handler); return lib::error_code(); } @@ -781,7 +781,7 @@ protected: return lib::error_code(); } - /*void handle_inturrupt(inturrupt_handler handler) { + /*void handle_interrupt(interrupt_handler handler) { handler(); }*/ diff --git a/websocketpp/transport/iostream/base.hpp b/websocketpp/transport/iostream/base.hpp index 84b27bf3a1..1fc5d9cb19 100644 --- a/websocketpp/transport/iostream/base.hpp +++ b/websocketpp/transport/iostream/base.hpp @@ -38,6 +38,7 @@ namespace transport { /// Transport policy that uses STL iostream for I/O and does not support timers namespace iostream { +/// iostream transport errors namespace error { enum value { /// Catch-all error for transport policy errors that don't fit in other @@ -58,6 +59,7 @@ enum value { bad_stream }; +/// iostream transport error category class category : public lib::error_category { public: category() {} @@ -84,11 +86,13 @@ class category : public lib::error_category { } }; +/// Get a reference to a static copy of the iostream transport error category inline lib::error_category const & get_category() { static category instance; return instance; } +/// Get an error code with the given value and the iostream transport category inline lib::error_code make_error_code(error::value e) { return lib::error_code(static_cast(e), get_category()); }