spelling, documentation, and style

This commit is contained in:
Peter Thorson
2013-06-23 21:06:33 -05:00
parent ce410a9428
commit 256f8325e8
9 changed files with 62 additions and 72 deletions

View File

@@ -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;

View File

@@ -30,20 +30,13 @@
#include <cstdlib>
// For htonl
#if defined(WIN32)
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif
#include <websocketpp/processors/processor.hpp>
#include <websocketpp/frame.hpp>
#include <websocketpp/utf8_validator.hpp>
#include <websocketpp/common/network.hpp>
#include <websocketpp/common/md5.hpp>
#include <websocketpp/processors/processor.hpp>
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<std::string> & subprotocols) const
lib::error_code client_handshake_request(request_type& req, uri_ptr uri,
std::vector<std::string> 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<std::string> & 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<const char*>(&msg_hdr),1));
out->set_header(std::string(reinterpret_cast<char const *>(&msg_hdr),1));
// process payload
out->set_payload(i);
out->append_payload(std::string(reinterpret_cast<const char*>(&msg_ftr),1));
out->append_payload(std::string(reinterpret_cast<char const *>(&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

View File

@@ -41,28 +41,27 @@ template <typename config>
class hybi07 : public hybi08<config> {
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<config>(secure, server, manager, rng) {}
explicit hybi07(bool secure, bool server, msg_manager_ptr manager,
rng_type& rng)
: hybi08<config>(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<std::string> & subprotocols) const
lib::error_code client_handshake_request(request_type & req, uri_ptr uri,
std::vector<std::string> const & subprotocols) const
{
return error::make_error_code(error::no_protocol_support);
}
int get_version() const {
return 7;
}
private:
};
} // namespace processor
} // namespace websocketpp

View File

@@ -51,8 +51,8 @@ public:
: hybi13<config>(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<std::string> & subprotocols) const
lib::error_code client_handshake_request(request_type& req, uri_ptr uri,
std::vector<std::string> 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

View File

@@ -28,18 +28,11 @@
#ifndef WEBSOCKETPP_PROCESSOR_HYBI13_HPP
#define WEBSOCKETPP_PROCESSOR_HYBI13_HPP
// For htonl
#if defined(WIN32)
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif
#include <cassert>
#include <websocketpp/frame.hpp>
#include <websocketpp/utf8_validator.hpp>
#include <websocketpp/common/network.hpp>
#include <websocketpp/http/constants.hpp>
#include <websocketpp/processors/processor.hpp>

View File

@@ -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

View File

@@ -39,39 +39,36 @@
namespace websocketpp {
namespace transport {
/// Transport policy that uses boost::asio
namespace asio {
typedef lib::function<void(boost::system::error_code const &)>
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<void(boost::system::error_code const &)>
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<int>(e), get_category());
}

View File

@@ -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();
}*/

View File

@@ -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<int>(e), get_category());
}